Select to view content in your preferred language

how to enable a tool after adding the layers to arcmap

957
3
04-20-2010 01:54 AM
srinivasreddy
Deactivated User
I added a combo box control to the arc map from .NET form ,by implementing the itoolcontrol interface.Here i need to enable the added combobox only after the layer is added to the arc map other wise it has to be disabled.At this instance only  combox has to maintain the objectids of the features in the particular layer.Please help me which event is used for this situation.

     Thank you.....
0 Kudos
3 Replies
JohnHauck
Frequent Contributor
You can handle this by listening to IActiveViewEvents::ItemAdded and IActiveViewEvents::ItemDeleted events. Your validation code would go in the event handlers and would be a simple conditional statement to determine if the key layer has been added or removed.

Here are a few docs that you may find useful:

http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriCarto/IActiveViewEvents.htm

http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/12BF6F08-1B25-4002-9640-73D4EB0E6CED.htm

For the second link look at the Events topics.

Hope this helps!
0 Kudos
JeremySury
Emerging Contributor
I prefer to override the Enabled property of the BaseTool class.....

The following example enables the tool only when a raster layer is added to the map.

    Public Overrides ReadOnly Property Enabled() As Boolean
        Get
            Dim i As Integer
            For i = 0 To pMap.LayerCount - 1
                If TypeOf pMap.Layer(i) Is IRasterLayer Then
                    MyBase.m_enabled = True
                    Exit For
                Else
                    MyBase.m_enabled = False
                End If
            Next i
            Return MyBase.Enabled
        End Get
    End Property
0 Kudos
Kumaran
New Contributor

Could you share the Itoolcontrol implementation that you have done.

0 Kudos