本文共 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/