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

Cells dont go out of ReadOnly mode

Hi,

.Net Framework 2.0 , Syncfusion 7.103.0.30.

I have a Gridcontrol with editable cells, if i do gridControl1.Item(1, 1).ReadOnly = True it becomes readonly. But i cannot make it editable again even if i call gridControl1.Item(1, 1).ReadOnly = False.

This happens to any cell that i set to readonly = true, when i do that i can not bring it back to readonly = false no matter what i do.

Any ideas?

4 Replies

LS Lingaraj S Syncfusion Team July 6, 2009 01:07 PM UTC

Hi,

Thank you for your interest in Syncfusion product.

If you want to set the ReadOnly cell in GridControl,then please try using QueryCellStyleInfo event in GridControl to achive this behaviour.

Please refer the code below:

Private flag As Boolean = True
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
If e.RowIndex = 1 AndAlso e.ColIndex = 1 Then
If flag Then
e.Style.ReadOnly = True
Else
e.Style.ReadOnly = False
End If
End If
End Sub


Refer the sample in below link:
http://files.syncfusion.com/support/samples/Grid.Windows/forums/Grid.zip

Please let me know if you have any queries.

Regards,
Lingaraj S.


XX xx July 6, 2009 11:33 PM UTC

Thanks for the reply.

It seems that wont work in this case as well, as I am trying to make a certain range in the row to be readonly = false.

example:

Private Sub gridTrips_CellDoubleClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Handles gridTrips.CellDoubleClick

For i = 1 To 9
gridTrips.Item(1, i).ReadOnly = False
gridTrips.Item(e.RowIndex, i).BackColor = Color.Yellow
Next

End Sub

----

I have also tried your code with "If e.RowIndex = 1 AndAlso e.ColIndex < 3 Then" but that affects the whole row not just cells 1 to 2.

What i do not understand is why in Syncfusion doing gridTrips.Item(1, 1).ReadOnly = True WORKS , but doing gridTrips.Item(1, 1).ReadOnly = false right after it DOES NOT.

A bug? Your comments and workarounds are much appreciated.


AD Administrator Syncfusion Team July 8, 2009 11:50 PM UTC

Wondering if you missed this as there is alot of spam on the forums lately.


LS Lingaraj S Syncfusion Team July 10, 2009 03:24 PM UTC

Hi,

Thank you for the update.

Setting something to ReadOnly will be ReadOnly even to the programmer. If you set _grid.ColStyles[1].BackColor = Color.Blue;, then this will not show blue in the

column since the styles were previously marked ReadOnly. So, to later set properties on readonly styles, you first must call grid.IgnoreReadonly = true;, make your

changes, and then reset IgnoreReadonly to false.

Refer the code below:

private void Form1_Load(object sender, EventArgs e)
{
this.gridControl1[1, 1].ReadOnly = true;
this.gridControl1[1, 2].ReadOnly = true;
}
private void button1_Click(object sender, EventArgs e)
{
this.gridControl1.IgnoreReadOnly = true ;
this.gridControl1[1, 1].ReadOnly = false;
this.gridControl1.IgnoreReadOnly = false;
}


Please let me know if you have any queries.Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon