DataGridViewCell.ReadOnly DataGridViewCell.ReadOnly DataGridViewCell.ReadOnly DataGridViewCell.ReadOnly Property

定義

取得或設定值,指出是否可以編輯儲存格的資料。Gets or sets a value indicating whether the cell's data can be edited.

public:
 virtual property bool ReadOnly { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
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.

-或--or-

設定此屬性時,會共用主控資料列。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.ReadOnly設定或DataGridViewColumn.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.

適用於

另請參閱