Udostępnij za pośrednictwem


How to: Set the Selection Mode of the Windows Forms DataGridView Control

The following code example demonstrates how to configure a DataGridView control so that clicking anywhere within a row automatically selects the entire row, and so that only one row at a time can be selected.

Example

With Me.dataGridView1
    .SelectionMode = DataGridViewSelectionMode.FullRowSelect
    .MultiSelect = False 
End With
this.dataGridView1.SelectionMode =
    DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.MultiSelect = false;

Compiling the Code

This example requires:

See Also

Concepts

Selection Modes in the Windows Forms DataGridView Control

Reference

DataGridView

MultiSelect

SelectionMode

DataGridViewSelectionMode

Other Resources

Selection and Clipboard Use with the Windows Forms DataGridView Control