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

Multiline text entry

I have a virtual grid which uses resize to fit to allow for data that wraps past the end of the cell. I want to allow the user to type into a cell and have it automatically resize to accommodate the text. It almost works, but there is a problem. As the text is being entered, when it reaches the end of the line, the cell resizes to accommodate a second line, but at that point the entire text of the cell gets selected. Of course, the next character the user types replaces all of the text that he had entered so far. How can I prevent the text from being selected at that point? This doesn''t happen when the text wraps at the end of any other line but the first.

4 Replies

AD Administrator Syncfusion Team July 26, 2005 04:40 PM UTC

I tried to reproduce this problem in this little sample and could not see it using 3.2.1.0. Can you? http://www.syncfusion.com/Support/user/uploads/GC_AutoSize_40676c40.zip Are you doing something that might be causing he grid (and or teh embedded textbox) to lose focus? That might affect this. Are you doing anything to select all the text at some other point in your code? If you can upload a little sample showing teh problem, maybe we can suggest something.


BC Bill Coyle July 26, 2005 06:08 PM UTC

You can reproduce this behavior by adding the following line to Form1_Load in your sample: gridControl1.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll; I want the cell text to be selected when the user clicks on the cell, but I don''t want that to happen when the cell resizes.


AD Administrator Syncfusion Team July 26, 2005 06:53 PM UTC

I don''t really have a nice selution for this. You can not use that property, and manually select the text in a timer tick after a mouse click.
Timer t = null;
private void gridControl1_GridControlMouseUp(object sender, Syncfusion.Windows.Forms.CancelMouseEventArgs e)
{
	if(t == null)
	{
		t = new Timer();
		t.Interval = 30;
		t.Tick += new EventHandler(t_Tick);
	
	}
	t.Start();
}

private void t_Tick(object sender, EventArgs e)
{
	t.Stop();
	GridTextBoxCellRenderer cr = this.gridControl1.CurrentCellRenderer as GridTextBoxCellRenderer;
	if(cr != null)
	{
		
		cr.TextBox.SelectAll();
		Console.WriteLine("gridControl1_GridControlMouseUp");
	}
}


BC Bill Coyle July 26, 2005 07:42 PM UTC

Thanks. For now, I think I''ll go with the GridCellActivateAction.SetCurrent option.

Loader.
Live Chat Icon For mobile
Up arrow icon