The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator 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