c# winform RowEnter 获得选中的DataGridView中的行的字段值

private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
	int rowIndex = e.RowIndex;//获取当前行
			
	string s = dataGridView1.Rows[rowIndex].Cells["xh"].Value.ToString(); //获取当前行xh字段的值

	MessageBox.Show(s);
}


这样就获得了选中的DataGridView中的行的字段值

黑色头发:http://heisetoufa.iteye.com/

你可能感兴趣的:(C++,c,C#,WinForm)