We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Toggle GridControl ReadOnly

Hello All,

I have a large gridcontrol. Some of the cells are readonly and some of them are not. (even in same columns it can differ)
Wenn the users clicks on a button the grid has to become readonly. Wenn the users clicks again on the button the user can edit the grid again like it was before.
The enabled property is just what i need. The only problem then is that you can''t scroll.

I don''t wont to redraw the grid or to recalcualte which cells are editable and which are not, because i did it ones at startup.

Just need to toggle between readonly and the status as it was before.


thx in advance
Gert



1 Reply

AD Administrator Syncfusion Team August 24, 2006 08:50 AM UTC

Hi Gert,

Instead of setting the Enabled property of the grid, you can handle the CurretCellActivating event to cancel the activates on current cell. Below is a code snippet.

bool isReadOnly = false;
private void EnabledButton4_Click(object sender, System.EventArgs e)
{
isReadOnly = !isReadOnly;
this.grid.CurrentCellActivating +=new GridCurrentCellActivatingEventHandler(grid_CurrentCellActivating);
this.grid.Selections.Clear();
}

private void grid_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{ e.Cancel = isReadOnly; }

private void grid_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{e.Cancel = isReadOnly;}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/ReadOnlyGrid_5b46d9aa.zip

Let me know if this helps.
Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon