Windows desktop applications
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Make Columns Read-Only in the Windows Forms DataGridView Control Using the Designer

 

By default, users can modify text and numerical data displayed in the Windows Forms DataGridView control. If you want to display data that is not meant for modification, you must make the columns that contain the data read-only. For information about how to make the control entirely read-only, see How to: Prevent Row Addition and Deletion in the Windows Forms DataGridView Control Using the Designer.

The following procedure requires a Windows Application project with a form containing a DataGridView control. For information about setting up such a project, see b2f93fed-c635-4705-8d0e-cf079a264efa and How to: Add Controls to Windows Forms.

System_CAPS_noteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

To make a column read-only by using the designer

  1. Click the smart tag glyph (Smart Tag Glyph) on the upper-right corner of the DataGridView control, and then select Edit Columns.

  2. Select a column from the Selected Columns list.

  3. In the Column Properties grid, set the ReadOnly property to true.

    System_CAPS_noteNote

    You can also make a column read-only when you add it by selecting the Read Only check box in the Add Column dialog box.

Show:
© 2016 Microsoft