首页 > 代码库 > ArcEngine添加地图属性字段

ArcEngine添加地图属性字段

        /// <summary> 
        /// 添加地图属性字段 
        /// </summary> 
        /// <param name="name">名称</param> 
        /// <param name="aliasName">别名</param> 
        /// <param name="length">长度</param> 
        /// <param name="defaultValue">默认值</param> 
        /// <param name="editAble">是否可以编辑</param> 
        public void addmapAttribute(string name, string aliasName, string length, string defaultValue, bool editAble)
        {
            try
            {
                ///////////////////////增加 
                IFieldEdit pMyField;
                pMyField = new FieldClass();
                pMyField.Name_2 = name;
                pMyField.AliasName_2 = aliasName;
                //pMyField.Type_2=type; 
                pMyField.Length_2 = Convert.ToInt32(length);

                if (defaultValue.Equals(""))
                { }
                else
                {
                    pMyField.DefaultValue_2 = defaultValue;
                }
                //转载请注明 arcengine吧 http://tieba.baidu.com/f?kw=arcengine   
                pMyField.Editable_2 = editAble;
                //pMyField.Type_2=esriFieldType.esriFieldTypeString; 
                ITable pTable = (ITable)axMap1.get_Layer(cboLayers.SelectedIndex);
                pTable.AddField(pMyField);
            }
            catch (Exception exc)
            {
                MessageBox.Show("添加失败" + exc.Message);
            }
        }

 

ArcEngine添加地图属性字段