This documentation is archived and is not being maintained.

DataGridTableStyle.ReadOnly Property

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

[Visual Basic]
Public Overridable Property ReadOnly As Boolean
public virtual bool ReadOnly {get; set;}
public: __property virtual bool get_ReadOnly();
public: __property virtual void set_ReadOnly(bool);
public function get ReadOnly() : Boolean;
public function set ReadOnly(Boolean);

Property Value

true, if columns can 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.


[Visual Basic, C#, C++] The following example returns the ReadOnly property for each DataGridTableStyle in a GridTableStylesCollection.

[Visual Basic] 
Private Sub PrintReadOnlyValues()
    Dim tableStyle As DataGridTableStyle
    For Each tableStyle In  dataGrid1.TableStyles
    Next tableStyle
End Sub 'PrintReadOnlyValues

private void PrintReadOnlyValues()
    foreach(DataGridTableStyle tableStyle in dataGrid1.TableStyles)

void PrintReadOnlyValues()
    System::Collections::IEnumerator* myEnum = dataGrid1->TableStyles->GetEnumerator();
    while (myEnum->MoveNext())
        DataGridTableStyle* tableStyle = __try_cast<DataGridTableStyle*>(myEnum->Current);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataGridTableStyle Class | DataGridTableStyle Members | System.Windows.Forms Namespace