0
在数据网格视图(已填充)对象上尝试此代码,当我做出选择时,我总是得到0个选定的行。Datagridview.selectedrows.count总是返回0?
Private Function IsThereASelection(ByVal e As DataGridView) As Boolean
If e.SelectedRows.Count <> 0 Then
MsgBox("You have selected " & e.SelectedRows.Count & " Rows.")
IsThereASelection = True
End If
MsgBox("You have selected " & e.SelectedRows.Count & " Rows.")
IsThereASelection = False
End Function
一些按钮的代码:
IsThereAselection(Window.DataGridView1)
EDIT1:我已经改变了datagridrow对象选择模式FullRowSelect
但它不会仍然工作。编辑2:我在按钮代码中使用了错误的引用(如上所示)。正确的参考将是DataGridView1,这将回答我的问题。
你确定你有'推选',而不仅仅是一个lagatagridcell'吗? – User999999
是的,朋友。每当我构建窗口时,我将鼠标指向选择该行的小三角形并点击它。 –
然后,你需要提供更多的代码,我很害怕。 – User999999