示例#1
0
        /// <summary>
        /// 显示选中属性
        /// </summary>
        public void ShowSelectionAttribute()
        {
            this.pAttributeMode              = AtrributesMode.SelectionAttribute;
            this.tSB_AllAttribute.Checked    = false;
            this.tSB_SelectAttribute.Checked = true;

            this.SetDataGridViewColumn();  //设置DataGridView的列

            //设置 DataGridView的行
            IFeatureSelection pFeatureSelection = (IFeatureSelection)Variable.pAttributeTableFeatureLayer;
            IEnumIDs          pEnumIDs          = pFeatureSelection.SelectionSet.IDs;
            int pFid = pEnumIDs.Next();

            while (pFid != -1)
            {
                IFeature pFeature  = Variable.pAttributeTableFeatureLayer.FeatureClass.GetFeature(pFid);
                object[] cellValue = new object[dataGridView1.ColumnCount];  //新建一行
                for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
                {
                    cellValue[i] = pFeature.get_Value(i);
                    if (cellValue[i] != null && cellValue[i].ToString().Trim() == "")
                    {
                        cellValue[i] = null;
                    }
                }
                this.dataGridView1.Rows.Add(cellValue);
                pFid = pEnumIDs.Next();
            }
            dataGridView1.ClearSelection();// 清除所有选中单元格
            toolStripStatusLabel1.Text = string.Format("选中了 {0} 条记录,共 {1} 条记录", this.dataGridView1.SelectedRows.Count, this.dataGridView1.RowCount);
        }
示例#2
0
        /// <summary>
        /// 显示所有属性
        /// </summary>
        public void ShowAllAttribute()
        {
            this.pAttributeMode              = AtrributesMode.AllAttribute;
            this.tSB_AllAttribute.Checked    = true;
            this.tSB_SelectAttribute.Checked = false;
            this.SetDataGridViewColumn();                                                                         //设置DataGridView的列
            //设置DataGridView的行
            IFeatureCursor pFeatureCursor = Variable.pAttributeTableFeatureLayer.FeatureClass.Search(null, true); //true表示每执行一次NextFeature(),上一个Feature将立即被回收
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                object[] cellValue = new object[this.dataGridView1.ColumnCount];//新建一行
                for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
                {
                    cellValue[i] = pFeature.get_Value(i);
                    if (cellValue[i] != null && cellValue[i].ToString().Trim() == "")
                    {
                        cellValue[i] = null;
                    }
                }
                this.dataGridView1.Rows.Add(cellValue);
                pFeature = pFeatureCursor.NextFeature();
            }
            this.dataGridView1.ClearSelection();  //清除所有选中单元格
            toolStripStatusLabel1.Text = string.Format("选中了 {0} 条记录,共 {1} 条记录", this.dataGridView1.SelectedRows.Count, this.dataGridView1.RowCount);
        }