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

Select all data in cell regardless of cell type

Is there a way in the code that you can select all the data in a cell regardless of the cell type? For instance if i want to click a button that will highlight the whole cell and have it look as it would if I used your selectall activate event? Can this be done or do you have to first figure out the cell type and then do each one individually?

4 Replies

AD Administrator Syncfusion Team June 30, 2004 10:13 AM

If you are willing to live with the ActivateCurrentCellBehavior.SelectAll setting, then just moving the current cell and then setting the focus back to the grid seems to work. But if you do not want this setting, then I think you would have to handle it celltype by celltype.
private void button1_Click(object sender, System.EventArgs e)
{
	this.grid.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;
			this.grid.CurrentCell.MoveTo(2,3);
			this.grid.Focus();
}


AD Administrator Syncfusion Team June 30, 2004 11:08 AM

That works but it always makes my activate property to selectall then. Is there any other way to do it where it wont change whatever that property may be? On a text box I have been just dimming a variable as a textbox and then setting it equal to the renderer control text and then do a select all of the text box. I can get this to work on some cell types but like on a currency cell type I cant.


AD Administrator Syncfusion Team June 30, 2004 12:44 PM

It is not too elegant, but it does work for a currencycell.
TextBox tb;
Timer timer1 = new System.Windows.Forms.Timer();


//in formload
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

private void button1_Click(object sender, System.EventArgs e)
{
	this.grid.CurrentCell.MoveTo(2,3, GridSetCurrentCellOptions.SetFocus);
	this.grid.Focus();
	this.tb = grid.CurrentCell.Renderer.Control as TextBox;
	if(this.tb != null)
		this.timer1.Enabled = true;
}

private void timer1_Tick(object sender, System.EventArgs e)
{
	this.timer1.Enabled = false;
	tb.SelectAll();
}


PB Philip Bishop July 1, 2004 06:19 AM

I am doing something kind of similar to what I think you are wanting and I have it working one of two ways. I''m not for sure if one is better then the other or which one I will end up using, but both appear to work. Dim cc As Grid.GridCurrencyTextBox = CType(Me.grdArrearsS.CurrentCell.Renderer.Control, Grid.GridCurrencyTextBox) cc.SelectAll() Dim tb As TextBox = CType(Me.grdArrearsS.CurrentCell.Renderer.Control, TextBox) tb.SelectAll()

Loader.
Live Chat Icon For mobile
Up arrow icon