VB.net中的DataGridView获取当前被选中的行号

Me.DataGridView1.CurrentCell.RowIndex  可以获取当前被选中的行号

可以定义一个静态全局的变量index

然后在SelectionChanged事件中为index=Me.DataGridView1.CurrentCell.RowIndex 

这样就可以动态的在其他地方使用当前被选中的行号index了

 

me.DataGridView1   .SelectedRows   (0).Cells(2).Value 或者 me.DataGridView1   .SelectedRows   (0).Cells("cloumns_name").Value 可以获取被选中行号中指定单元格的值

你可能感兴趣的:(WinForm)