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

How can select a cell in the first time clicking on it

I am implementing a grid with two Textbox cells: cell #1 is used to select (does not edit) and cell #2 is used to edit. Could you please help me to anwser questions below: 1) How can select all the text in editable cell in the first time clicking on it? 2) for Cell #1, How can it always select all text when cliking on it? thanks for your suporting!

5 Replies

AD Administrator Syncfusion Team January 5, 2005 07:37 AM UTC

I am not sure hwat the difference is between your requests 1 and 2. But you can cause all the text to be selected when you click on a cell by setting this property. this.gridDisplay.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;

DB David Bosak January 5, 2005 08:23 AM UTC

Thank you! For question #2, when click many times on cell, how is the text (on the cell) still selected (not select one word of text) ?

AD Administrator Syncfusion Team January 5, 2005 09:50 AM UTC

If you want to selectall on a doubleclick of an active cell (instead of selecting a word), handle the CurrentCellControlDoubleClick event. private void gridControl1_CurrentCellControlDoubleClick(object sender, ControlEventArgs e) { GridTextBoxControl tb = e.Control as GridTextBoxControl; if(tb != null) { tb.SelectAll(); } }

DA DavidBosak@venturipartners.com January 31, 2005 06:52 AM UTC

When using tb.SelectAll() or this.dgrTemplateManagement.ActivateCurrentCellBehavior = Syncfusion.Windows.Forms.Grid.GridCellActivateAction.SelectAll, How to show the text at the beginning of textBox? Thanks!

AD Administrator Syncfusion Team January 31, 2005 07:41 AM UTC

You can try handling the CurrentCellControlGotFocus event.
private void gridDataBoundGrid1_CurrentCellControlGotFocus(object sender, ControlEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl;
	if(tb != null)
		tb.SelectionStart = tb.Text.Length;
		tb.SelectionLength = 0;

Live Chat Icon For mobile
Up arrow icon