马兰花开贾石头:谁能帮我把这段vb改成c#啊?

来源:百度文库 编辑:高校问答 时间:2024/04/28 00:08:21
Private Sub UIBAttributeWindow_Click()
Call OpenAttribWnd
End Sub
Private Function UIBAttributeWindow_Enabled() As Boolean
Dim pMxDocument As IMxDocument
Dim pSelectedItem As IUnknown
Dim bEnabled As Boolean
Set pMxDocument = ThisDocument Set pSelectedItem = pMxDocument.SelectedItem
bEnabled = True
' Disable if the selected item is nothing or if
' it is not a layer or table
If pSelectedItem Is Nothing Then
bEnabled = False
ElseIf (TypeOf pSelectedItem Is IFeatureLayer) Or (TypeOf pSelectedItem Is IStandaloneTable) Then
bEnabled = True
End If

UIBAttributeWindow_Enabled = bEnabled
End Function
Private Sub OpenAttribWnd()
Dim pMxDocument As IMxDocument
Dim pLayer As ILayer
Dim pStandaloneTable As IStandaloneTable
Dim pSelectedItem As IUnknown
Dim pTableWindowExist As ITableWindow
Dim pTableWindow2 As ITableWindow2
Dim bSetProperties As Boolean
On Error GoTo ErrorHandler: Set pMxDocument = ThisDocument
Set pSelectedItem = pMxDocument.SelectedItem
Set pTableWindow2 = New TableWindow
' Determine the selected item's type
' Exit sub if item is not a feature layer or standalone table
If TypeOf pSelectedItem Is IFeatureLayer Then
Set pLayer = pSelectedItem
Set pTableWindowExist = pTableWindow2.FindViaLayer(pLayer)
' Check if a table already exist; if not create one
If pTableWindowExist Is Nothing Then
Set pTableWindow2.Layer = pLayer
bSetProperties = True
End If

ElseIf TypeOf pSelectedItem Is IStandaloneTable Then
Set pStandaloneTable = pSelectedItem
Set pTableWindowExist = pTableWindow2.FindViaStandaloneTable(pStandaloneTable)
' Check if a table already exists; if not, create one
If pTableWindowExist Is Nothing Then
Set pTableWindow2.StandaloneTable = pStandaloneTable
bSetProperties = True
End If
End If

If bSetProperties Then
pTableWindow2.TableSelectionAction = esriSelectFeatures
pTableWindow2.ShowSelected = False
pTableWindow2.ShowAliasNamesInColumnHeadings = True
Set pTableWindow2.Application = Application
Else
Set pTableWindow2 = pTableWindowExist
End If ' Ensure Table Is Visible
If Not pTableWindow2.IsVisible Then
pTableWindow2.Show True
End If
Exit Sub
ErrorHandler:
MsgBox Err.Description
End Sub

太多了