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

Feature Request: Really Static Cells

Hi, We have had this discussion before in late 2002. Most of us have a requirement of having a cell which can never be modified by the user. Right now there is a cell type called Static. It comes close. You can not type over it. But it lets you Cut (Ctrl-X) the text and lets you delete the text using DEL key. Ideally we would like to have a "Really Static Cell" which the user can not modify using any GUI interactions like cut/paste/delete/ backspace/type any key in it. It should be enabled so that the contents can be copied. Its contents should be modifiable programatically without setting any other flags like IgnoreReadOnly = true etc. How are other users handling this kind of issues? thanks, - Reddy

5 Replies

AD Administrator Syncfusion Team October 29, 2003 10:55 PM UTC

With the later code bases, (1.6.1.8 or 2.0.0.5 and higher), you can use this code to make a cell unchangeable as long as you are not letting the grid be an OLE DND drop target. GridStyleInfo style = this.gridControl1[2,2]; style.CellType = "Static"; style.Text = "SomeText"; style.ReadOnly = true; If you want a particular cell to be absolutely immutable (including to OLE DND), then you can handle SaveCellInfo, and not save the change. Make sure you subscribe to the event after you set the cell text otherwise, the change will not take.
//in formload
GridStyleInfo style = this.gridControl1[2,2];
style.Text = "SomeText";
this.gridControl1.SaveCellInfo += new GridSaveCellInfoEventHandler(this.gridControl1_SaveCellInfo);

//the handler
private void gridControl1_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
{
	if(e.ColIndex == 2 && e.RowIndex == 2)
	{
		e.Handled = true;
	}
}


AD Administrator Syncfusion Team October 30, 2003 12:23 PM UTC

Clay, This is exactly what I was refering to. Why should we go through these events for what appears to be so simple and should have been part of the toolkit. In all my data bound grids, if I have to handle this kind of events it will be too much of code. So having a cell that the user can not change through GUI would be nice. If you look around in any grid, there would be atleast couple of columns that are never editable by user. E.g.: Windows Explorer -> except name, everything else is "Really static". This is a very very common thing in all database oriented applications to have static columns in grids that should only be modifiable through APIs. thanks, - Reddy


AD Administrator Syncfusion Team October 30, 2003 03:54 PM UTC

The correct scenario as it was initially planned is that the .ReadOnly setting of a cell will not allow any further changes to any cell information of that cell. So if you make a cell "Static" and .ReadOnly no method should be able to change it unless IgnoreReadOnly was set. However, in early version of the grid we were not checking the .ReadOnly setting carefull enough so that's why that original idea was not working with some methods (e.g. with ClearCells, Clipboard and other methods). We'll enforce .ReadOnly more strictly in future. Stefan


AD Administrator Syncfusion Team June 8, 2004 11:21 AM UTC

Is this ever going to be fixed for clipboard operations. I have a feeling that 99% of people who set a cell as readonly do not want the contents of the cell erased on a Cut operation, which is the current behaviour. >The correct scenario as it was initially planned is that the .ReadOnly setting of a cell will not allow any further changes to any cell information of that cell. So if you make a cell "Static" and .ReadOnly no method should be able to change it unless IgnoreReadOnly was set. > >However, in early version of the grid we were not checking the .ReadOnly setting carefull enough so that''s why that original idea was not working with some methods (e.g. with ClearCells, Clipboard and other methods). We''ll enforce .ReadOnly more strictly in future. > >Stefan >


AD Administrator Syncfusion Team June 8, 2004 11:43 AM UTC

In 2.0.5.1, if I drop a GridControl on a form, and set this code in FormLoad, selecting a range including 2,2 and pressing ctl-X does not affect cell 2,2 for me.
private void Form1_Load(object sender, System.EventArgs e)
{
	this.gridControl1.ChangeCells(GridRangeInfo.Cells(1,1,5,5), "abc");
	this.gridControl1[2,2].BackColor = Color.LightBlue;
	this.gridControl1[2,2].ReadOnly = true;
}

Loader.
Live Chat Icon For mobile
Up arrow icon