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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

23798 Jan 19,2005 08:10 PM Jan 20,2005 07:34 AM Windows Forms 4
loading
Tags: GridControl
David Bosak
Asked On January 19, 2005 08:10 PM

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

David Bosak
Replied On January 20, 2005 12:08 AM

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 12:26 AM

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

David Bosak
Replied On January 20, 2005 02:22 AM

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 07:34 AM

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.

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.

;