更新:2007 年 11 月
下面的代码示例演示如何配置 DataGridView 控件以便单击某一行的任何位置都将自动选择整行,并且一次只能选择一行。
示例
With Me.dataGridView1
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.MultiSelect = False
End With
this.dataGridView1.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.MultiSelect = false;
编译代码
此示例需要:
名为 dataGridView1 的 DataGridView 控件。
对 System 和 System.Windows.Forms 程序集的引用。
请参见
概念
Windows 窗体 DataGridView 控件中的选择模式