DataGridViewCell.ReadOnly 属性


获取或设置一个值,该值表示是否可以编辑该单元格的数据。Gets or sets a value indicating whether the cell's data can be edited.

 virtual property bool ReadOnly { bool get(); void set(bool value); };
public virtual bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Overridable Property ReadOnly As Boolean


如果无法编辑该单元格的数据,则为 true;否则为 falsetrue if the cell's data cannot be edited; otherwise, false.



设置此属性时不存在所属行。There is no owning row when setting this property.


设置此属性时共享所属行。The owning row is shared when setting this property.


ReadOnly 属性指示是否可以编辑单元格显示的数据。The ReadOnly property indicates whether the data displayed by the cell can be edited. 您可以为个别单元格设置 ReadOnly,也可以通过设置 DataGridViewRow.ReadOnlyDataGridViewColumn.ReadOnly 属性,使整个单元或列的单元格成为只读的。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. 您可以通过为个别单元格设置 ReadOnly 来重写此默认行为。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 仅影响单元格是否可编辑;它不会影响用户是否可以删除行。ReadOnly only affects whether a cell is editable; it does not affect whether the user can delete rows.