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.
Syncfusion Feedback

Highlighting text in edit mode

Thread ID:

Created:

Updated:

Platform:

Replies:

16451 Jul 15,2004 01:49 PM UTC Jul 16,2004 08:03 PM UTC Windows Forms 11
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 15, 2004 01:49 PM UTC

How can I highlight the text within the edit box when I double clicked on the cell?

Administrator [Syncfusion]
Replied On July 15, 2004 02:12 PM UTC

One way you can try to do this is to handle the CurrentCellControlDoubleClick event and select the text there.
private void grid_CurrentCellControlDoubleClick(object sender, ControlEventArgs e)
{
	GridCurrentCell cc = this.grid.CurrentCell;
	if(!cc.IsEditing)
		cc.BeginEdit();
	GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl;
	if(tb != null)
		tb.SelectAll();
}

Administrator [Syncfusion]
Replied On July 15, 2004 03:25 PM UTC

this doesn''t hightlight the text when I first double click on the cell to activate it. This event is fired when the cell is activated and double clicking on the activated cell again. so it doesn''t work.

Administrator [Syncfusion]
Replied On July 15, 2004 03:53 PM UTC

It seems to work for me in this sample using 2.0.5.1. What are you doing differently? SetCurrent_4977.zip

Administrator [Syncfusion]
Replied On July 15, 2004 04:07 PM UTC

You have the ActivateCurrentCellBehavior set to ClickOnCell and I have it set to DblClickOnCell. I don''t want the cell to be activated when I single click onto it. I want the text to be highlighted when I double click onto the cell (from non-activate to activate).

Administrator [Syncfusion]
Replied On July 15, 2004 04:54 PM UTC

In this case, set this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.None; Then handle the CellDoubleClick event.
private void gridControl1_CellDoubleClick(object sender, GridCellClickEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	cc.BeginEdit();
	GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl;
	if(tb != null)
		tb.SelectAll();
}

Administrator [Syncfusion]
Replied On July 15, 2004 05:30 PM UTC

it works great for textbox control. For combo box type cell, it goes into edit mode for single click. Is there a way to preven the combo box goes into edit mode for single click? It would be nice to have the combo box activated on double click.

Administrator [Syncfusion]
Replied On July 15, 2004 07:40 PM UTC

I only see the problem when DropDownStyle = GridDropDownStyle.Exclusive; (or if I click directly on the button with one of the other settings). Here is one try at dynamically handling showing the combobox only after teh cell has been doubleclicked. SetCurrent_2501.zip

Administrator [Syncfusion]
Replied On July 16, 2004 11:42 AM UTC

The sample is close enough to what I want. I found couple bugs, Issue 1 --------- - double click on the combo box to make it active. - double click one of the text cell (D, 4). - switch to another window and back. you will see the combo box is visible again. Issue 2 --------- The text box is no long highlighted when double clicked. Issue 3 --------- This is a general grid/combo box issue. When you have the drop down list visible, resizing the column will not resize the drop down box. Issue 4 --------- This is my application specific. If I have the combo-box drop down list visible, clicking on the main application area does not make the list goes away. So when I drag the window aray, the drop down list stays at the same location. Is there any way I can handle this myself to remove the drop down list?

Administrator [Syncfusion]
Replied On July 16, 2004 12:52 PM UTC

Here is a revamped sample that handles problems 1 & 2. It uses different events. 3) This is by design. You can set the width yourself in CurrentCellShowingDropdown as in the sample. 4) The list should close when the grid loses focus. You can try catching the grid''s Leave event and calling grid.CurrentCell.CloseDropDown at that point. BUt I am not sure this event will be hit in your case but you could try it. SetCurrent_1308.zip

Administrator [Syncfusion]
Replied On July 16, 2004 05:36 PM UTC

Re 4), in my case, the drop down list (or grid) didn''t lose focus when I click on the main window title bar. But in your case (sample code), the drop down goes away if I click on the title bar. The combo box must listen for another event, not the lost focus event.

Administrator [Syncfusion]
Replied On July 16, 2004 08:03 PM UTC

Our popup logic uses an IMessageFilter to trap such a click. Below is a call stack showing what happens in the sample when you click the title bar. I am not sure what might interfere with the IFilterMessage listener. Do you have any CausesValidation properties set to false? Do you have any class that implements IMessageFilter? comboclose_7500.zip

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

;