I'm creating a tool in ArcMap 10 using a windows form... its been a struggle (maybe some of you recognize the same themes in my questions) because this is the first time I've really messed with ArcObjects and VB.Net... either way I'm almost there!! (Largely thanks to a very helpful GIS community.)
The main chunk of the code works (grabs an attribute from one layer and assigns it to the "target" layers), and now I'm in the process of linking up the user parameters.
As it stands, the "NHD Reach Layer" combo box (cmbNHD) requires the source layer be in the table of contents (TOC).
The target layers, on the other hand, can either be in the TOC (through the "Target Layers" combo box (cmbTarget), or accessible through the GxDialog. Either way, the selections are placed in the list box (boxTarget).
... Dim pLayer As IFeatureLayer Dim pGxDataset As IGxDataset = pGxObjects.Next Do Until pGxDataset Is Nothing pLayer = New FeatureLayer pLayer.FeatureClass = pGxDataset.Dataset pLayer.Name = pLayer.FeatureClass.AliasName If Not boxTarget.Items.Contains(pLayer.Name) Then boxTarget.Items.Add(pLayer.Name) pGxDataset = pGxObjects.Next Loop End Sub
OK, so what I can't figure out, is how to form some "loopable" list from the items in the list box. The original code worked only with the items in the table of contents, and so it could loop through them all using this type of loop...
For i = 0 To pMap.LayerCount - 1 Dim pLayer = pMap.Layer(i)
...and just skipping the index number of the source layer ("NHD Reach Layer").
AND SO, I'm pretty sure I just need to create an enumeration of the layers in the list box, but I've only been able to dig up the IEnumLayers interface, and it seems as if that only works with the layers in the current map.
Also, I'm not sure if this is the place (though, I can't think of a better one), but when this is all finished, I was wondering if I could post the final code (the reason I ask is because it wouldn't really be a question). I've spent a good amount of energy trolling through forums and developer help files to find relatively simple answers in the form of examples, but usually they are snippets, which, when viewed out of context, can be confusing. It's my belief that this code would be really helpful to anybody just getting started, because it offers few frills, and combines a lot of basic methods with some intermediates thrown in here and there. Just trying to help.
Thanks so much!!