好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C#中Winfrom开发双击DataGridView选中一行并取字段值

C#中Winfrom开发双击DataGridView选中一行并取字段值

在构造函数中入以下代码

DataGridView1.CellDoubleClick += new DataGridViewCellEventHandler(DataGridCell_DoubleClick);

然后再建立以下方法,即可看效果

private void DataGridCell_DoubleClick(object sender, DataGridViewCellEventArgs e)

{

    DataGridView.HitTestInfo hitTest=DataGridView1.HitTest(e.RowIndex, e.ColumnIndex);

    DataGridView1.ClearSelection();

    DataGridView1.Rows[e.RowIndex].Selected = true;

    DataGridViewRow dr = DataGridView1.SelectedRows[0];

    MessageBox.Show(dr.Cells[0].Value.ToString() + "===" + dr.Cells[1].Value.ToString() + "===" + dr.Cells[2].Value.ToString() + "===" + dr.Cells[3].Value.ToString());

}


查看更多关于C#中Winfrom开发双击DataGridView选中一行并取字段值的详细内容...

  阅读:17次