private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Rows[e.RowIndex].Selected = true;
//选中行的第二列数据
lb_userId.Text = this.dataGridView1.Rows[e.RowIndex].Cells[1].value.Tostring();
//选中行的第三列数据
lb_userPw.Text = this.dataGridView1.Rows[e.RowIndex].Cells[2].value.Tostring();
}
} |