博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
datagridview 常用操作代码
阅读量:121 次
发布时间:2019-02-27

本文共 880 字,大约阅读时间需要 2 分钟。

得到当前单元格的 headText            this.dataGridView1.Columns[this.dataGridView1.CurrentCell.ColumnIndex].HeaderText得到当前单元格的 Name            string name = this.dataGridView1.Columns[this.dataGridView1.CurrentCell.ColumnIndex].Name;编程方式获得当前行private void getCurrentCellButton_Click(object sender, System.EventArgs e){    string msg = String.Format("Row: {0}, Column: {1}",        dataGridView1.CurrentCell.RowIndex,        dataGridView1.CurrentCell.ColumnIndex);    MessageBox.Show(msg, "Current Cell");}通过编程方式设置当前单元格设置 DataGridView 控件的 CurrentCell 属性。在下面的代码示例中,当前单元格设置为 0 行 1 列。 private void setCurrentCellButton_Click(object sender, System.EventArgs e){    // Set the current cell to the cell in column 1, Row 0.             this.dataGridView2.CurrentCell = this.dataGridView1[1, 0]; //第0行第1列}            this.dataGridView1.Columns[this.dataGridView1.CurrentCell.ColumnIndex].HeaderText

转载地址:http://eerf.baihongyu.com/

你可能感兴趣的文章