Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataGridTableStyle.ReadOnly Property

Gets or sets a value indicating whether columns can be edited.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public virtual bool ReadOnly { get; set; }
/** @property */
public boolean get_ReadOnly ()

/** @property */
public void set_ReadOnly (boolean value)

public function get ReadOnly () : boolean

public function set ReadOnly (value : boolean)

Not applicable.

Property Value

true, if columns cannot be edited; otherwise, false.

You can also specify whether individual columns within the table are editable by setting the DataGridColumnStyle class's DataGridColumnStyle.ReadOnly property to an appropriate value, true or false.

Alternatively, to ensure that the data is not edited, you can set the DataColumn class's ReadOnly property to true.

The following code example returns the ReadOnly property for each DataGridTableStyle in a GridTableStylesCollection.

private void PrintReadOnlyValues()
{
    foreach(DataGridTableStyle tableStyle in dataGrid1.TableStyles)
    {
      Console.WriteLine(tableStyle.ReadOnly);
    }
}


private void PrintReadOnlyValues()
{
    DataGridTableStyle tableStyle;
    for (int iCtr=0;iCtr < dataGrid1.get_TableStyles().get_Count();iCtr++) {
        tableStyle = dataGrid1.get_TableStyles().get_Item(iCtr);
        Console.WriteLine(tableStyle.get_ReadOnly());
    }
} //PrintReadOnlyValues

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

Show:
© 2015 Microsoft