Skip to main content
added 404 characters in body
Source Link
Barbarossa
  • 5.8k
  • 1
  • 28
  • 62

If you want to get the alias name of the underlying feature class, you have to cast the layer as an IFeatureLayer, and then grab the AliasName from the featurelayer.featureclass. See my code:

Dim enumLayer As IEnumLayer = My.ArcMap.Document.FocusMap.Layers(Nothing, True)
enumLayer.Reset()
Dim layer As ILayer = enumLayer.Next
Do Until layer Is Nothing
    If TypeOf layer Is IFeatureLayer Then
        Dim fl As IFeatureLayer = CType(layer, IFeatureLayer)
        MessageBox.Show(String.Format("Layer {0} has an alias name of {1}", layer.Name, fl.FeatureClass.AliasName))
    End If
    layer = enumLayer.Next
Loop

EDIT: To get the alias name of each field in the attribute table, you will need to grab the fields object either from a feature or featureclass object. See below. I just grab a reference to a featureclass from a featurelayer.

Dim fc as IFeatureClass = fl.FeatureClass
Dim fields as IFields = fc.Fields

for i = 0 to fields.FieldCount - 1
    Dim field As IField = fields.Field(i)
    MessageBox.Show(field.AliasName)
Next

If you want to get the alias name of the underlying feature class, you have to cast the layer as an IFeatureLayer, and then grab the AliasName from the featurelayer.featureclass. See my code:

Dim enumLayer As IEnumLayer = My.ArcMap.Document.FocusMap.Layers(Nothing, True)
enumLayer.Reset()
Dim layer As ILayer = enumLayer.Next
Do Until layer Is Nothing
    If TypeOf layer Is IFeatureLayer Then
        Dim fl As IFeatureLayer = CType(layer, IFeatureLayer)
        MessageBox.Show(String.Format("Layer {0} has an alias name of {1}", layer.Name, fl.FeatureClass.AliasName))
    End If
    layer = enumLayer.Next
Loop

If you want to get the alias name of the underlying feature class, you have to cast the layer as an IFeatureLayer, and then grab the AliasName from the featurelayer.featureclass. See my code:

Dim enumLayer As IEnumLayer = My.ArcMap.Document.FocusMap.Layers(Nothing, True)
enumLayer.Reset()
Dim layer As ILayer = enumLayer.Next
Do Until layer Is Nothing
    If TypeOf layer Is IFeatureLayer Then
        Dim fl As IFeatureLayer = CType(layer, IFeatureLayer)
        MessageBox.Show(String.Format("Layer {0} has an alias name of {1}", layer.Name, fl.FeatureClass.AliasName))
    End If
    layer = enumLayer.Next
Loop

EDIT: To get the alias name of each field in the attribute table, you will need to grab the fields object either from a feature or featureclass object. See below. I just grab a reference to a featureclass from a featurelayer.

Dim fc as IFeatureClass = fl.FeatureClass
Dim fields as IFields = fc.Fields

for i = 0 to fields.FieldCount - 1
    Dim field As IField = fields.Field(i)
    MessageBox.Show(field.AliasName)
Next
Source Link
Barbarossa
  • 5.8k
  • 1
  • 28
  • 62

If you want to get the alias name of the underlying feature class, you have to cast the layer as an IFeatureLayer, and then grab the AliasName from the featurelayer.featureclass. See my code:

Dim enumLayer As IEnumLayer = My.ArcMap.Document.FocusMap.Layers(Nothing, True)
enumLayer.Reset()
Dim layer As ILayer = enumLayer.Next
Do Until layer Is Nothing
    If TypeOf layer Is IFeatureLayer Then
        Dim fl As IFeatureLayer = CType(layer, IFeatureLayer)
        MessageBox.Show(String.Format("Layer {0} has an alias name of {1}", layer.Name, fl.FeatureClass.AliasName))
    End If
    layer = enumLayer.Next
Loop