且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在用户控件中选择一行dgv

更新时间:2023-02-05 12:31:27

确保选择适当的选择选项:
 myDataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect 



请参阅:

https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionmode%28v=vs.110% 29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/3c89df86%28v=vs.110%29.aspx [ ^ ]。



-SA
E>

I have created a workable program that uses several identical user controls containing text boxes and a datagridview control. Every things works as planned except clicking on the datagridview control row header does not select the row. What could cause a row to not be selectable?

Make sure you choose appropriate selection option:
myDataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect


Please see:
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionmode%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/3c89df86%28v=vs.110%29.aspx[^].

—SA