AnsweredAssumed Answered

vb.net  arcobjects show fields from feature

Question asked by sig102014 on Aug 3, 2015
Latest reply on Aug 4, 2015 by kenbuja

 

A big hello,

 

I try to show the field names (alias names) of a feature class. I found a code snippet but I don't succeed to get it to run

Can somebody tell me please what is wrong in the code? (System: Arcgis 10.2, Visual Studio2012)

Thanks a lot for any help!!

 

 

Imports ESRI.ArcGIS.esriSystem

Imports ESRI.ArcGIS.Carto

Imports ESRI.ArcGIS.ArcMapUI

Imports ESRI.ArcGIS.Geodatabase


Public Class AnzahlFelderButton

Inherits ESRI.ArcGIS.Desktop.AddIns.Button

 

Public Sub New()

End Sub

 

Protected Overrides Sub OnClick()

ShowDistinctFieldAliasNames(My.ArcMap.Document)

End Sub


Shared Sub ShowDistinctFieldAliasNames(ByVal featureClass As IFeatureClass)

 

      Dim fields As IFields = featureClass.Fields

      Dim field As IField = Nothing


      For i As Integer = 0 To fields.FieldCount - 1

      ' Get the field at the given index.

      field = fields.Field(i)

           If field.Name <> field.AliasName Then

                Console.WriteLine("{0} : {1}", field.Name, field.AliasName)

           End If

      Next

      MsgBox(field.AliasName)

      My.ArcMap.Application.CurrentTool = Nothing

End Sub


 

Protected Overrides Sub OnUpdate()

Enabled = My.ArcMap.Application IsNot Nothing

End Sub


 

Private Sub DisplayDistinctFieldAliasNames()

Throw New NotImplementedException

End Sub

 

End Class


 

Outcomes