日期:2014-05-19  浏览次数:20617 次

DataGridView 问题[winform]
dataGridView1.SelectionMode   =   DataGridViewSelectionMode.FullRowSelect;
....
....

                private   void   dataGridView1_CellMouseClick(object   sender,   DataGridViewCellMouseEventArgs   e)
                {
                        /*
                              在用户单击一行的时候怎么获取用户单击的这行数据的每列的值呢?*/                        
                }


------解决方案--------------------
得到所点击的行的各个单元格的内容如下:
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
DataGridViewRow row = (sender as DataGridView).Rows[e.RowIndex];
for (int i = 0; i < row.Cells.Count; i++)
{
System.Console.WriteLine(row.Cells[i].Value);
}
}