以下程式碼範例示範如何設定 DataGridView 控制項,以便按一下資料列內的任何位置時會自動選取整個資料列,並且一次只能選取一個資料列。
範例
this.dataGridView1.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.MultiSelect = false;
With Me.dataGridView1
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.MultiSelect = False
End With
正在編譯程式碼
這個範例需要:
名為
dataGridView1的 DataGridView 控制項。System 和 System.Windows.Forms 組件的參考。