-
-
Duncan Hornby
If you feel my response answered your question please vote it up, I want to be famous! 
-
0
Re: ArcMap 9.2 VS2005 starting conversion from VBA to dotnet
Evidently no could help me so I figured it out on my own.
Not actually that much different than VBA.
Public Overrides Sub OnMouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer)
'TODO: Add RetrunAttributes.OnClick implementation
'TODO: Add RetrunAttributes.OnMouseUp implementation
'Get project vital data
Dim pMxDoc As IMxDocument
Dim myApp As IMxApplication
myApp = m_application
pMxDoc = CType(m_application.Document, IMxDocument)
'Get the map and layer information
Dim pMap As IMap
pMap = pMxDoc.FocusMap
Dim pEnumLayer As IEnumLayer
pEnumLayer = pMap.Layers
pEnumLayer.Reset()
Dim pLayer As ILayer
pLayer = pEnumLayer.Next
Dim pFLayer As IFeatureLayer
Do While Not pLayer Is Nothing
If pLayer.Name = "tlots" And TypeOf pLayer Is IFeatureLayer Then ' Substitute your real layer name
pFLayer = TryCast(pLayer, IFeatureLayer)
Exit Do
End If
pLayer = pEnumLayer.Next
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Get the users' clicked point
'Create an envelope at the point
'Select the feature at the clicked location with the envelope
Dim clickedPoint As IPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y)
Dim pEnvelope As Envelope = clickedPoint.Envelope
Dim pView As IActiveView = pMap
pEnvelope.Expand(pMxDoc.SearchTolerance, pMxDoc.SearchTolerance, False)
pMap.SelectByShape(pEnvelope, myApp.SelectionEnvironment, False)
pView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Check to make sure the layer is available
If pFLayer Is Nothing Then
MsgBox("No Layer Found")
Exit Sub
End If
'Check to make sure a feature is selected
Dim pFSel As IFeatureSelection
pFSel = pFLayer
Dim pSelSet As ESRI.ArcGIS.Geodatabase.ISelectionSet2
pSelSet = pFSel.SelectionSet
If pSelSet.Count < 1 Then
MsgBox("No Features Selected")
Return
End If
Using comReleaser As ComReleaser = New ComReleaser() ' Recommended for cleaning up cursors
Dim pFCursor As ESRI.ArcGIS.Geodatabase.IFeatureCursor = Nothing
pSelSet.Search(Nothing, False, pFCursor)
comReleaser.ManageLifetime(pFCursor)
Dim pFeature As IFeature
pFeature = pFCursor.NextFeature ' Get First Feature
If pFeature Is Nothing Then
MsgBox("No Features Selected!") ' Just in case, but probably already taken care of earlier
Return
End If
'Return the appropriate attribute from the selected feature
Dim lFIndex As Long
lFIndex = pFCursor.FindField("Acad_Text") ' Replace with your field name
If lFIndex > -1 Then
Do While Not pFeature Is Nothing
fValue = pFeature.Value(lFIndex) 'I declare the fValue above the region
pFeature = pFCursor.NextFeature
Loop
End If
'Display the selected attribute
MsgBox(fValue)
End Using
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks