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 to select all the content of one cell when clicking this cell?

When user clicks a cell on the GDBG, how to select all the content of one cell?

4 Replies

DB David Bosak January 20, 2005 05:08 AM UTC

I tried the following codes, it only move the cursor from start to end, not select all of text: GridCurrentCell cc = this.dgrLookup.CurrentCell; cc.BeginEdit(); GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl; if(tb != null) { tb.SelectionStart = 0; tb.SelectionLength = tb.Text.Length; }


AD Administrator Syncfusion Team January 20, 2005 05:26 AM UTC

Instead of tb.SelectionStart = 0; tb.SelectionLength = tb.Text.Length; try tb.SelectAll();


DB David Bosak January 20, 2005 07:22 AM UTC

The same as the result above. private void dgrLookup_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) { GridCurrentCell cc = this.dgrLookup.CurrentCell; cc.BeginEdit(); GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl; if(tb != null) { //dgrLookup.Focus(); //tb.SelectionStart = 0; //tb.SelectionLength = tb.Text.Length; tb.SelectAll(); } }


AD Administrator Syncfusion Team January 20, 2005 12:34 PM UTC

There is a property that you can set so that all the text is selected anytime the cell becomes current. this.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll; But this will select all whether you click the cell or move with the cursor keys. To only do it whne you click, use your code above, but also add e.Cancel = true. Without this, the grid continues to process the click which will do whatever the ActivateCurrentCellBehavior indicates.

Loader.
Live Chat Icon For mobile
Up arrow icon