set specified column to readonly
Now I use loop implement set specified column to readonly like follow:
for(int i = 1; i <= grid.Model.RowCount; i++)
{
grid.Model[i, 4].ReadOnly = true;
}
Is there an easier way?
And, although has been set to readonly, click the cell, cell can get focus, how to make the cell cant't be focused when readonly?
for(int i = 1; i <= grid.Model.RowCount; i++)
{
grid.Model[i, 4].ReadOnly = true;
}
Is there an easier way?
And, although has been set to readonly, click the cell, cell can get focus, how to make the cell cant't be focused when readonly?
SIGN IN To post a reply.
4 Replies
LK
luo kun
September 28, 2009 01:40 AM UTC
In addition, it looks like the same code doesn't work right on Grid Tree Control.
GK
Ganesan K
Syncfusion Team
September 28, 2009 11:45 AM UTC
Hi luokun,
Thanks for using Syncfusion products.
You can use VisibleColumns collection for set the entire column as ReadOnly in GridDataControl
[C#]
this.gridControl.VisibleColumns[colIndex].IsReadOnly = true;
[XAML]
You can listen the Grid_CurrentCellActivating event as below to avoid the ReadOnly cell get focused.
void Grid_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{
if (e.CellRowColumnIndex.ColumnIndex == 2)
{
e.Cancel = true;
}
}
Please download the workaround sample from the below locaion and check it out.
http://www.syncfusion.com/uploads/redirect.aspx?file=GridDataControlSample_c611563c.zip&team=development
You can use Columns collection in GridTreeControl for set the entire column as ReadOnly.
treeGrid.Columns[2].StyleInfo.ReadOnly = true;
Let me know if you need any more details.
Thanks
Ganesan
Thanks for using Syncfusion products.
You can use VisibleColumns collection for set the entire column as ReadOnly in GridDataControl
[C#]
this.gridControl.VisibleColumns[colIndex].IsReadOnly = true;
[XAML]
You can listen the Grid_CurrentCellActivating event as below to avoid the ReadOnly cell get focused.
void Grid_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{
if (e.CellRowColumnIndex.ColumnIndex == 2)
{
e.Cancel = true;
}
}
Please download the workaround sample from the below locaion and check it out.
http://www.syncfusion.com/uploads/redirect.aspx?file=GridDataControlSample_c611563c.zip&team=development
You can use Columns collection in GridTreeControl for set the entire column as ReadOnly.
treeGrid.Columns[2].StyleInfo.ReadOnly = true;
Let me know if you need any more details.
Thanks
Ganesan
LK
luo kun
September 29, 2009 01:34 AM UTC
The code can only be used GridDataControl,Grid Control is no similar way?
And GridTreeControl hasn't Grid_CurrentCellActivating event also.
And GridTreeControl hasn't Grid_CurrentCellActivating event also.
CB
Clay Burch
Syncfusion Team
September 29, 2009 09:27 AM UTC
In the GridTreeControl, if you do not want a column to ever have a current cell (meaning that it cannot be clicked or tabbed into), you can set the the style.Enabled property to false. (This way, the column would not receive focus.)
To subscribe to currentcell events in the GridTreeControl, use its InternalGrid property (which exposes a GridControl derived class). You should subscribe to such events in the GridTreeControl ModelLoaded event. For example,
There are no column properties in a GridControl. To set properties on a column in a GridControl, you would need to handle the QueryCellInfo event, and if e.Cell.ColumnIndex points to a particular column, you would then set the properties you want for that column on the e.Style object (like e.Style.ReadOnly = true, or like e.Style.Enabled = false).
For a GridDataControl, the only column properties are those directly exposed in the VisibleColumn (like ReadOnly mentioned in a previous post in this thread). If you want to directly set other style properties you can use gridDataControl.Model.QueryCellInfo as described in the previous paragraph for GridControl.
treeGrid.Columns[2].StyleInfo.Enabled = false;
To subscribe to currentcell events in the GridTreeControl, use its InternalGrid property (which exposes a GridControl derived class). You should subscribe to such events in the GridTreeControl ModelLoaded event. For example,
treeGrid.ModelLoaded += (s, e) =>
{
treeGrid.InternalGrid.CurrentCellActivating += new GridCurrentCellActivatingEventHandler(InternalGrid_CurrentCellActivating);
};
There are no column properties in a GridControl. To set properties on a column in a GridControl, you would need to handle the QueryCellInfo event, and if e.Cell.ColumnIndex points to a particular column, you would then set the properties you want for that column on the e.Style object (like e.Style.ReadOnly = true, or like e.Style.Enabled = false).
For a GridDataControl, the only column properties are those directly exposed in the VisibleColumn (like ReadOnly mentioned in a previous post in this thread). If you want to directly set other style properties you can use gridDataControl.Model.QueryCellInfo as described in the previous paragraph for GridControl.
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
-
LK luo kun
- Sep 27, 2009 02:15 AM UTC
- Sep 29, 2009 09:27 AM UTC