Geodatabase-Modify Field alias (Fields alias)

Source: Internet
Author: User

The following code demonstrates opening a feature class from a personal database and modifying a specified field alias, where it is important to note that it cannot be obtained directly from the Axmapcontrol in the engine, as

1  // get Ifeatureclass directly. 2 // ESRI. ArcGIS.Carto.ILayer lyr = mapctrl_main.get_layer (0); 3 // ESRI. ArcGIS.Carto.IFeatureLayer Flyr = (ESRI. ArcGIS.Carto.IFeatureLayer) Lyr; 4 // ESRI. ArcGIS.Geodatabase.IFeatureClass FC = Flyr. Featureclass;

This is not possible:

1 /// <summary>2         ///Modify the field alias.3         /// </summary>4         /// <param name= "Personalworkspacepath" >Personal database Path (can of course be a different type of database), such as "G:\doc\gis\1.400\data\pdb.mdb"</param>5         /// <param name= "Featureclassname" >feature class name, such as "Hyd1_4l_1"</param>6         /// <param name= "Orifieldname" >The original field alias, such as "Fnode_".</param>7         /// <param name= "Desfieldname" >The new field alias, such as "Fnode".</param>8         Private voidAlterfieldaliasname (stringPersonalworkspacepath,stringFeatureclassname,stringOrifieldname,stringdesfieldname) {9             //get Ifeatureclass through Ifeatureworkspace.TenESRI. ArcGIS.Geodatabase.IWorkspaceFactory WSF =NewESRI. ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass (); OneESRI. ArcGIS.Geodatabase.IWorkspace ws = WSF. Openfromfile (Personalworkspacepath,0); AESRI. ArcGIS.Geodatabase.IFeatureWorkspace FWS =(ESRI. ArcGIS.Geodatabase.IFeatureWorkspace) ws; -ESRI. ArcGIS.Geodatabase.IFeatureClass FC =FWS. Openfeatureclass (featureclassname); -  theESRI. ArcGIS.Geodatabase.ITable T =(ESRI. ArcGIS.Geodatabase.ITable) FC; -             if(T.findfield (orifieldname) = =-1)//No field name specified. -                 return; -  +ESRI. ArcGIS.Geodatabase.IObjectClass objclass =(ESRI. ArcGIS.Geodatabase.IObjectClass) FC; -ESRI. ArcGIS.Geodatabase.ISchemaLock Slock =(ESRI. ArcGIS.Geodatabase.ISchemaLock) objclass; +             Try { A Slock. Changeschemalock (ESRI. ArcGIS.Geodatabase.esriSchemaLock.esriExclusiveSchemaLock); atESRI. ArcGIS.Geodatabase.IClassSchemaEdit Cschemaedit =(ESRI. ArcGIS.Geodatabase.IClassSchemaEdit) T; - cschemaedit.alterfieldaliasname (Orifieldname, desfieldname); -MessageBox.Show (" Done"); -             } -             Catch(System.Exception ex) { - MessageBox.Show (ex. Message); in             } -             finally { to                 if(Slock! =NULL) + Slock. Changeschemalock (ESRI. ArcGIS.Geodatabase.esriSchemaLock.esriSharedSchemaLock); -             } the}

Geodatabase-Modify Field alias (Fields alias)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.