Friday, May 6, 2011

How to make XtraGrid GridControl Columns ReadOnly

Here are several possible solutions.
1. The first solution is to set the Editable option of the GridView.OptionsBehavior property
    to False. In this case, the whole grid becomes read-only.
    Select GridControl and click on the arrow on right-top select Run Designer. In the Properties
    List go to Options->OptionsBehaviour->Editable= False.. set this property to false.

2. Another solution is to cahnge the ReadOnly or AllowEdit option of your columns.
3. The last solution is to use the ShowingEditor event of the view and disable cell editing via
    code using the event handler's e.Cancel parameter.
The OptionsColumn property is part of the GridColumn class.

Open the designer for a GridControl, select a GridView, then click on the Columns icon in the Main section of the NavBar shown at
the left of the designer. This is where you manage your GridColumn objects for the selected GridView. Near the bottom of the
property list on the right side of the designer will be shown the options for a selected column.

Programmatically, you may do the following to make all columns read-only (C#):

foreach( GridColumn gridColumn in gridView1.Columns )
gridColumn.OptionsColumn.ReadOnly = true;

No comments :

Post a Comment