Problem executing built-in command

643
1
12-06-2011 08:49 AM
KevinOrcutt
New Contributor
Howdy All,
     Here's a quick one (I hope!)...  I'm working on a ArcMap add-in that has a form in it that has two buttons, one for "Clear Selection" and the othe for "Selecting features"...  I can get the "Clear Selection" to work, but can't seem to figure out how to get the Select Features" one to work...  Here is what I have for code:

    'Someplace in the solution these are defined and set...
    Public g_pMxDoc As IMxDocument
    Public g_application As IApplication

       .
       .
       .


    g_pMxDoc = My.ArcMap.Document
    g_application = My.ArcMap.Application

       .
       .
       .


   'In the form's code I have the following:
   Private Sub btnClearSelection_Click(sender As System.Object, e As System.EventArgs) Handles btnClearSelection.Click
        Dim pCommand As ICommand
        pCommand = New ControlsClearSelectionCommand
        pCommand.OnCreate(g_application)
        pCommand.OnClick()
    End Sub



   Private Sub btnSelectFeatures_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectFeatures.Click
        Dim pCommand As ICommand
        pCommand = New ControlsSelectFeaturesToolClass
        pCommand.OnCreate(g_application)
        g_pMxDoc.CurrentTool = pCommand
        pCommand.OnClick()
    End Sub



When I "Click" the "Select" buttom, it ges through the code fine, but it does not let me select anything on the map...   The cursor doesn't change and the selection tool is presently set for select by box...  When I drag over features (form a box), nothing is selected

This is in an ArcMap 10 Add-in written in VB .Net

Current Environment:
ArcMap 10.0 Service Pack 3, ArcInfo license level
ArcObjects SDK, Service Pack 1
Visual Studio 2010 Professional, Service Pack 1
VB.Net


Any ideas as to what I did wrong and/or how to correct this????

Thanks in advance,
Kevin Orcutt
0 Kudos
1 Reply
NeilClemmons
Regular Contributor III
Unless I'm mistaken, the classes you're using are the built-in classes for ArcEngine.  I doubt they are designed to work inside ArcGIS Desktop.  The way you would do this at 9.3.1 (and as far as I'm aware also at 10) is to use IDocument::CommandBars to get a reference to the ArcMap command/tool and execute it.
0 Kudos