Home Forums WinForms controls Xceed Grid for WinForms Double click on grid?? Reply To: Double click on grid??

User (Old forums)
Member
Post count: 23064

Is your grid ReadOnly? If so, this should work fine.

If not, however, the double click event will be on the editor of the cell, not on the cell itself. Here is what you need to do to get the double click event. This code snippet assumes cells are of string data type, thus using a simple TextBoxEditor.

You need to subscribe to TextBox events through the ActivatingControl event of the CellEditorManager. This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.

e.g.:

//at Form_Load
<i>
private void Form1_Load(object sender, System.EventArgs e)
{
gridControl1.Columns[ 0 ].CellEditorManager.ActivatingControl += new CellEditorEventHandler(CellEditorManager0_ActivatingControl);
gridControl1.Columns[ 0 ].CellEditorManager.DeactivatingControl += new CellEditorEventHandler(CellEditorManager0_DeactivatingControl);
</i>
//Event Handlers
<i>
private void CellEditorManager0_ActivatingControl(object sender, CellEditorEventArgs e)
{
( ( WinTextBox )e.Control).TextBoxArea.DoubleClick += new EventHandler(TextBoxArea_DoubleClick);
}

private void CellEditorManager0_DeactivatingControl(object sender, CellEditorEventArgs e)
{
//need to unsubscribe, if not, the subscriptions will kept pilling up!
( ( WinTextBox )e.Control).TextBoxArea.DoubleClick -= new EventHandler(TextBoxArea_DoubleClick);
}

private void TextBoxArea_DoubleClick(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine( sender.ToString() );
}
</i>

Imported from legacy forums. Posted by André (had 347 views)