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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to select all the content of one cell when clicking this cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

23798 Jan 20,2005 01:10 AM UTC Jan 20,2005 12:34 PM UTC WinForms 4
loading
Tags: GridControl
David Bosak
Asked On January 20, 2005 01:10 AM UTC

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

David Bosak
Replied On 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; }

Administrator [Syncfusion]
Replied On January 20, 2005 05:26 AM UTC

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

David Bosak
Replied On 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(); } }

Administrator [Syncfusion]
Replied On 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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;