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

GridAwareTextBox and read only cells

I have a virtual grid and a GridAwareTextBox. Some of the cells in my grid are read only, but the GridAwareTextBox doesn't seem to pick up on that, and so allows editing of the cell. Is there a way to prevent this, or do I need to hook one of the grid events and set the read only property of the text box as the cell changes? Thanks, Sue

5 Replies

AD Administrator Syncfusion Team September 12, 2003 03:50 AM

Currently, you will have to handle this yourself. Below is one place you can do it. Setting the textBox to readonly will gray the background. If you do not want this, you can reset it as below.
private void grid_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
{
	GridCurrentCell cc = this.gridControl2.CurrentCell;
	this.gridAwareTextBox2.ReadOnly = this.gridControl2[cc.RowIndex, cc.ColIndex].ReadOnly;
	if(this.gridAwareTextBox2.ReadOnly)
		this.gridAwareTextBox2.BackColor = Color.White;
}


JB John Baker March 4, 2004 08:47 AM

This works great, but my CellHeader text shows up in the textbox when I select a column. How do we clear the gridawaretextbox without clearing the cell? IE. If you don''t want cell values showing when readonly. >Currently, you will have to handle this yourself. Below is one place you can do it. Setting the textBox to readonly will gray the background. If you do not want this, you can reset it as below. > >
>private void grid_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
>{
>	GridCurrentCell cc = this.gridControl2.CurrentCell;
>	this.gridAwareTextBox2.ReadOnly = this.gridControl2[cc.RowIndex, cc.ColIndex].ReadOnly;
>	if(this.gridAwareTextBox2.ReadOnly)
>		this.gridAwareTextBox2.BackColor = Color.White;
>}
>
>


AD Administrator Syncfusion Team March 4, 2004 10:53 AM

You can handle the Header Text not showing by handling CurretnCellActivating and cancelling if you are on the header row. private void gridControl1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e) { if(e.RowIndex == 0) e.Cancel = true; } This does not work for interior cells unless you want not to ss the currentcell frame when you click one. (This normally does not cause a problem with header, but does with regular cells.


JB John Baker March 12, 2004 12:04 PM

Well, I want to be able to select the whole column; I just don''t want the header text to show up in the GridAwareTextBox when a header cell is the currentcell. I tried to set GridAwareTextBox1.text = "", but that zaps the header from my grid. >You can handle the Header Text not showing by handling CurretnCellActivating and cancelling if you are on the header row. > >private void gridControl1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e) >{ > if(e.RowIndex == 0) > e.Cancel = true; >} > > >This does not work for interior cells unless you want not to ss the currentcell frame when you click one. (This normally does not cause a problem with header, but does with regular cells.


AD Administrator Syncfusion Team March 12, 2004 02:45 PM

Did you try the above code, and it did not work? It seems to work for me in this sample, and you can still select the column. GridAwareTB_9402.zip

Loader.
Live Chat Icon For mobile
Up arrow icon