AnsweredAssumed Answered

Can't figure out a problem with a form

Question asked by rkelso on Mar 8, 2012
Latest reply on Mar 12, 2012 by rkelso
I've got an ArcMap add-in button that opens a form I've created, it has a listbox where all the feature layers in the map are added.  I can dispose of the form after I'm done, make some changes in the ToC, like change layer names, add/remove layers, etc. then open the form again and it works no problem, any changes I've made are reflected on the list.

The problem I'm having is if I activate a different data frame with a different set of layers then reload the form, the list of layers doesn't change from the previous data frame.  Or if I open a different mxd by going File > Open or File > click any recently used maps then it doesn't think there are any feature layers in the map when there really are.

I am highly inexperienced at this stuff so I'm sure my code has all kinds of things you more experienced folks would facepalm at, but I really need some help figuring out how to fix this issue because I don't even know what to try at this point.  Here is a sample of what happens when I open the form and thanks for any ideas!!

    Dim Doc As IMxDocument = My.ArcMap.Application.Document     Dim Map As IMap = Doc.FocusMap      Dim uid As ESRI.ArcGIS.esriSystem.IUID     Dim enumLayer As IEnumLayer     Dim layer As ILayer      uid = New ESRI.ArcGIS.esriSystem.UIDClass     uid.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"     enumLayer = Map.Layers(uid, True)      enumLayer.Reset()     layer = enumLayer.Next      Dim MapLayerForm1 As New MapLayerForm      Do While Not (layer Is Nothing)         MapLayerForm1.ListOfFeatureLayers.Items.Add(layer.Name)         layer = enumLayer.Next()     Loop      MapLayerForm1.ShowDialog()

Outcomes