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

Setting properties on Read-Only cells.

I would like to know why this behavior is what it is: I set a cell to readonly. I change the backcolor of the cell for the first time - it works. When I go to change it back to another color later, it suddenly doesn''t work. I am using just a GridControl (not a databoundgrid). I am curious as to why it works once, but no more times thereafter (unless I set Grid.Model.IgnoreReadOnly to false, change the color, and then set the IgnoreReadOnly back to TRUE again. What''s the dilly?

3 Replies

AD Administrator Syncfusion Team August 26, 2004 05:27 AM UTC

If I drop a GridControl on a form, and add a button, and a buttonclick handler like this:
private void button1_Click(object sender, System.EventArgs e)
{
	this.gridControl1[2,2].ReadOnly = true;
	this.gridControl1[2,2].BackColor = Color.Red;
}
clicking the button does not change the color of the cell for me. If you are seeing the color change the first time, I suspect you are executing the change code at some point the grid has the original style cached (maybe its the style for the current cell, and you are trying to set it while the cell is editing or something), and it is the cached old style that is allowing the first change to take. Just a guess. If you can post a sample showing the behavior, we can probably provide a more concrete explanation.


TO Ted Osberg August 26, 2004 11:39 AM UTC

I made a mistake. I set the ReadOnly thru the ColStyles. Does setting properties thru the Cell itself trump the ColStyles? I know that RowStyles trump ColStyles, so does setting the actual Cell properties override both ColStyles and RowStyles? >If I drop a GridControl on a form, and add a button, and a buttonclick handler like this: >
>private void button1_Click(object sender, System.EventArgs e)
>{
>	this.gridControl1[2,2].ReadOnly = true;
>	this.gridControl1[2,2].BackColor = Color.Red;
>}
>
>clicking the button does not change the color of the cell for me. If you are seeing the color change the first time, I suspect you are executing the change code at some point the grid has the original style cached (maybe its the style for the current cell, and you are trying to set it while the cell is editing or something), and it is the cached old style that is allowing the first change to take. Just a guess. > >If you can post a sample showing the behavior, we can probably provide a more concrete explanation.


AD Administrator Syncfusion Team August 26, 2004 11:59 AM UTC

Yes. Cell specific setting have the highest precedence.

Loader.
Live Chat Icon For mobile
Up arrow icon