I am trying to migrate my program from ArcMap 10 VBA to ArcObjects VB.net add-in in Visual studio express 2008. I write a ArcGIS addin component tool to draw a geometry, perform a spatial query and then pop out a windows form with radio buttons to decide based on which layers in TOC to perform the query. Now what I have encountered is in OnMouseDown Event the radiobutton read from current form and return no value. when I execute the code it opens the form as i expected but doesn't allow me to select radiobutton, besides it doesnot show any error or relevant warnings in VS express errorlist.
Here are the codes in Tool Class
Public Class Tool1
Inherits ESRI.ArcGIS.Desktop.AddIns.Tool
Dim frm2 As New Form2
Public Sub New()
End Sub
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
Protected Overrides Sub OnMouseDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs)
' MyBase.OnMouseDown(arg)
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pActiveView As IActiveView
pMxDoc = My.ArcMap.Document
pActiveView = pMxDoc.FocusMap
pMap = pMxDoc.FocusMap
Call AddDataFromFile.AddShapeFile("\\Hkhkgsv02\GIS\Basemap\Database_Index", "B1k_index")
Call AddDataFromFile.AddShapeFile("\\Hkhkgsv02\GIS\Basemap\Database_Index", "B5k_index")
Call AddDataFromFile.AddShapeFile("\\Hkhkgsv02\GIS\Basemap\Database_Index", "B10k_index")
Call AddDataFromFile.AddShapeFile("\\Hkhkgsv02\GIS\Basemap\Database_Index", "B20k_index")
'Determine Selection Layer based on which scale
Dim pScreenDisplay As IScreenDisplay
Dim pRubberEnv As IRubberBand
pScreenDisplay = pActiveView.ScreenDisplay
pRubberEnv = New RubberEnvelope
Dim pEnvelope As IEnvelope
pEnvelope = pRubberEnv.TrackNew(pScreenDisplay, Nothing)
'Rectangle Display
If pEnvelope.IsEmpty = True Then Exit Sub
With pScreenDisplay
.StartDrawing(pScreenDisplay.hDC, ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache)
.FinishDrawing()
End With
Dim pGeometry As IGeometry
pGeometry = pEnvelope
'Build a Spatial Query Filter
Dim pSFilter As ISpatialFilter
pSFilter = New SpatialFilter
pSFilter.Geometry = pGeometry
pSFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains
frm2.Show()
If frm2.RadioButton1.Checked = True Then
pFlayer = pMxDoc.FocusMap.Layer(FindLayerIndex.Find_Layer_Index("B1k"))
ElseIf frm2.RadioButton2.Checked = True Then
pFlayer = pMxDoc.FocusMap.Layer(FindLayerIndex.Find_Layer_Index("B5k"))
ElseIf frm2.RadioButton3.Checked = True Then
pFlayer = pMxDoc.FocusMap.Layer(FindLayerIndex.Find_Layer_Index("B10k"))
ElseIf frm2.RadioButton3.Checked = True Then
pFlayer = pMxDoc.FocusMap.Layer(FindLayerIndex.Find_Layer_Index("B20k"))
End If
Dim pSelectionLayer As IFeatureSelection
pSelectionLayer = pFlayer
If pFlayer Is Nothing Then Exit Sub
Dim pFeatureClass As IFeatureClass
Dim pFCursor As IFeatureCursor
pFeatureClass = pFlayer.FeatureClass
pFCursor = pFeatureClass.Search(pSFilter, True)
' Set Array to Store Feature Value
Dim NameValueArray() As String
ReDim NameValueArray(pFeatureClass.FeatureCount(pSFilter))
'Find Fieldindex to read Tile's Map Name
Dim intFieldIndex As Integer
intFieldIndex = pFeatureClass.FindField("TILE_NAME")
...
End Sub
End Class
Hope I can get some clue.thanks.
Jing
