Beispiel #1
0
        //读取图层属性表
        private void ReadLayerTabelField(ILayer layer, SuperGridControl superGrid)
        {
            superGridFields.PrimaryGrid.ClearAll();
            if (layer is IFeatureLayer)
            {
                IFeatureLayer featureLayer = layer as IFeatureLayer;
                if (featureLayer.FeatureClass == null)
                {
                    return;
                }
                IFields fields = featureLayer.FeatureClass.Fields;

                for (int i = 0; i < fields.FieldCount; i++)
                {
                    IField field = fields.get_Field(i);

                    GridRow row = new GridRow(field.Name, field.Type.ToString().Replace("esriFieldType", ""), field.Length.ToString());
                    superGrid.PrimaryGrid.Rows.Add(row);
                }
            }
            else if (layer is IRasterLayer)
            {
                ITable table = ClsGDBDataCommon.GetTableofLayer(m_pLayer);
                if (table != null)
                {
                    IFields fields = table.Fields;
                    for (int i = 0; i < fields.FieldCount; i++)
                    {
                        IField field = fields.get_Field(i);

                        GridRow row = new GridRow(field.Name, field.Type.ToString().Replace("esriFieldType", ""), field.Length.ToString());
                        superGrid.PrimaryGrid.Rows.Add(row);
                    }
                }
            }
        }