Select to view content in your preferred language

How to change aliasname from layer attributetable by arcobjects?

784
2
12-20-2013 03:34 AM
Andréde_Mattos_Ferraz
Deactivated User
Hi,

I want to change this attribute (see image below) at execution time. Any idea?
[ATTACH=CONFIG]30031[/ATTACH]


Thx in advance
0 Kudos
2 Replies
NeilClemmons
Honored Contributor
If you want to alter the alias in the data source itself, then use IClassSchemaEdit.AlterFieldAliasName.  If you only want to change it for the map document then use IFieldInfo.
0 Kudos
Andréde_Mattos_Ferraz
Deactivated User
Thx Neil!

This was my solution:

    public class AttributeTableManager
    {
        private IFeatureLayer _featureLayer;

        public AttributeTableManager(IFeatureLayer fl)
        {
            this._featureLayer = fl;
        }

        /// <summary>
        /// Altera o alias do campo
        /// </summary>
        /// <param name="fieldName">Name do campo na attributetable, ele é usado para procurar o campo correto e alterar o alias</param>
        /// <param name="alias">Alias que será definido para o campo</param>
        public void ChangeAliasName(string fieldName,string alias)
        {
            ILayerFields fields = this._featureLayer as ILayerFields;

            IFieldInfo fldInfo = fields.FieldInfo[fields.FindField(fieldName)];
            fldInfo.Alias = alias;
        }


    }
0 Kudos