readonly cannot be reset

I have a databound grid with a column that uses a user control. Depending on locks put by other users editing the same data, I want to make the grid read-only or editable. When the grid goes read-only, I want my user control to display in a different way, so I set the column that contains it to read-only. The control is then made read-only by the grid, and it can handle the special display mode. I use the following code to make the grid read-only or editable: void SetGridReadOnly( bool ReadOnly ) { if ( ReadOnly ) { this.grdRule.Model.ColStyles[2].ReadOnly = ReadOnly; this.grdRule.EnableAddNew = !ReadOnly; this.grdRule.Model.ReadOnly = ReadOnly; } else { this.grdRule.Model.ReadOnly = ReadOnly; this.grdRule.Model.ColStyles[2].ReadOnly = ReadOnly; this.grdRule.EnableAddNew = !ReadOnly; } } Alas, when I try to reset the ReadOnly property in the ColStyle, it does not work. The grid ignores the new setting. I noticed a similar behavior also with simple columns (e.g. a TextBox). In that case, I could set the style to static, and work around the problem. In this case I don''t know what to do. Can you help, please? Thanks. Regards, Raul Rosenthal SDB SpA

2 Replies

AD Administrator Syncfusion Team April 28, 2005 01:49 AM UTC

Hi Raul, Making a column readonly means that it cannot be changed (EVEN from code). If you later want to make a change to a readonly column, please set grid.IgnoreReadOnly = true, then make the change, and then set grid.ReadOnly back to false. This is by design. void SetGridReadOnly( bool ReadOnly ) { if ( ReadOnly ) { this.grdRule.Model.ColStyles[2].ReadOnly = ReadOnly; this.grdRule.EnableAddNew = !ReadOnly; this.grdRule.Model.ReadOnly = ReadOnly; } else { this.grdRule.IgnoreReadOnly = true; this.grdRule.Model.ReadOnly = ReadOnly; this.grdRule.Model.ColStyles[2].ReadOnly = ReadOnly; this.grdRule.EnableAddNew = !ReadOnly; this.grdRule.IgnoreReadOnly = false; } } Best regards, Jay N


RR Raul Rosenthal April 28, 2005 07:56 AM UTC

Thank you. I''ll try this way. Regards, Raul

Loader.
Up arrow icon