我就废话不多说了,大家还是直接看代码吧~ public static DataTable GetFeatureDataTable(IFeature pFeature) { DataTable dt = new DataTable(); dt.Columns.Add("位置:"); dt.Columns.Add("数据:"); for (int i = 0; i pFeature.Fie
我就废话不多说了,大家还是直接看代码吧~
public static DataTable GetFeatureDataTable(IFeature pFeature) { DataTable dt = new DataTable(); dt.Columns.Add("位置:"); dt.Columns.Add("数据:"); for (int i = 0; i < pFeature.Fields.FieldCount; i++) { DataRow dr = dt.NewRow(); dr[0] = pFeature.Fields.Field[i].Name; dr[1] = pFeature.Value[i]; dt.Rows.Add(dr); } return dt; }
补充:C#AE获取要素图层某个字段的唯一值
开始喔:
IFeatureLayer featureLayer=你要获取唯一值的图层 //存储唯一值字段 List<string> myValueList = new List<string>(); #region//获取唯一值字段 //数据统计 IDataStatistics dataStatistics = new DataStatisticsClass(); //设置统计字段 dataStatistics.Field = fieldName; //获取所有 dataStatistics.Cursor = (ICursor)featureLayer.FeatureClass.Search(null, false); IEnumerator myEnumerator = dataStatistics.UniqueValues; //获取该字段的唯一值字段 myEnumerator.Reset(); while (myEnumerator.MoveNext()) { if (!myValueList.Contains(myEnumerator.Current.ToString())) { myValueList.Add(myEnumerator.Current.ToString()); } } //指针释放(用完释放,养成良好习惯哈) System.Runtime.InteropServices.Marshal.ReleaseComObject(dataStatistics); #endregion
结束呦。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持自由互联。如有错误或未考虑完全的地方,望不吝赐教。