Export (0) Print
Expand All

DataGridViewCell.ReadOnly Property

Gets or sets a value indicating whether the cell's data can be edited.

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

[BrowsableAttribute(false)]
public virtual bool ReadOnly { get; set; }

Property Value

Type: System.Boolean
true if the cell's data cannot be edited; otherwise, false.

ExceptionCondition
InvalidOperationException

There is no owning row when setting this property.

-or-

The owning row is shared when setting this property.

The ReadOnly property indicates whether the data displayed by the cell can be edited. You can set ReadOnly for individual cells, or you can make an entire row or column of cells read-only by setting the DataGridViewRow.ReadOnly or DataGridViewColumn.ReadOnly properties. By default, if a cell's parent row or column is set to read-only, the child cells will adopt the same value. You can override this default behavior by setting ReadOnly for individual cells.

You can navigate to a read-only cell, and you can set a read-only cell to be the current cell.

ReadOnly only affects whether a cell is editable; it does not affect whether the user can delete rows.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft