DataGrid::ReadOnly Property

 

Gets or sets a value indicating whether the grid is in read-only mode.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
property bool ReadOnly {
	bool get();
	void set(bool value);
}

Property Value

Type: System::Boolean

true if the grid is in read-only mode; otherwise, false. The default is false.

In read-only mode, the grid can be scrolled, nodes can be expanded or collapsed, and so on. However, no additions, edits, or deletes can take place.

The DataGridColumnStyle also has a ReadOnly property that can be set to true to prevent data from being edited, on a column-by-column basis.

The ReadOnly can be set to true if you want to prohibit the user from editing the data directly in the System.Windows.Forms::DataGrid. For example, you might want to let users to see all columns in a table, but allow them to edit specific fields only through TextBox controls on a different form.

The following code example toggles the ReadOnly property.

Private Sub ToggleReadOnly(ByVal myGrid As DataGrid)
    myGrid.ReadOnly = myGrid.ReadOnly Xor True
 End Sub

.NET Framework
Available since 1.1
Return to top
Show: