แก้ไข

แชร์ผ่าน


DataGrid.ReadOnly Property

Definition

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

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

Property Value

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

Examples

The following code example toggles the ReadOnly property.

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

Remarks

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.

Applies to

See also