| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
How to: Set the Selection Mode of the Windows Forms DataGridView Control |
03/30/2017 |
.net-framework |
|
article |
|
|
2f241643-7f82-4583-8757-03494f63b465 |
12 |
dotnet-bot |
dotnetcontent |
wpickett |
How to: Set the Selection Mode of the Windows Forms DataGridView Control
The following code example demonstrates how to configure a xref:System.Windows.Forms.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
[!code-csharpSystem.Windows.Forms.DataGridViewMisc#065] [!code-vbSystem.Windows.Forms.DataGridViewMisc#065]
Compiling the Code
This example requires:
-
A xref:System.Windows.Forms.DataGridView control named
dataGridView1. -
References to the xref:System?displayProperty=nameWithType and xref:System.Windows.Forms?displayProperty=nameWithType assemblies.
See Also
xref:System.Windows.Forms.DataGridView
xref:System.Windows.Forms.DataGridView.MultiSelect%2A
xref:System.Windows.Forms.DataGridView.SelectionMode%2A
xref:System.Windows.Forms.DataGridViewSelectionMode
Selection and Clipboard Use with the Windows Forms DataGridView Control
Selection Modes in the Windows Forms DataGridView Control