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
close icon

Cell Double Click

I am trying to handle the double click event on a cell in a bound data grid. I'm doing this using the following as directed in other forum posts. grd.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell; grd.DoubleClick += new System.EventHandler(MyHandler); grd.CellDoubleClick += new Syncfusion.Windows.Forms.Grid.GridCellClickEventHandler(MyHandler); My problem occurs due to MyHandler opening a dialog form which on closing returns focus to the original form on which the grid resides. When, on this original form, I click on another cell in the grid, the double click event is fired. How can I prevent this happening ? Also, I'd like to be able to have access to the contents of the cell, say to highlight and copy some text. With the code above controlling the current cell behaviour I can only achieve this after a double click, which in this instance fires the double click event and takes me through the handling routine. Any thoughts as to how I might achieve this functionality whilst retaining my double click handling ? Essentially I'd like to be able highlight the cell details as though the ActivateCurrentCellBehavior value were not set to GridCellActivateAction.DblClickOnCell whilst being able to capture a double click within the cell. Is this possible ? Many thanks, Rob Hughes

2 Replies

AD Administrator Syncfusion Team April 9, 2003 09:00 PM UTC

Here is one way I think you can display a dialog on a double click and then have an active cell afterwards (without getting a Double event when you click the next cell) is to: 1) this.gridControl1.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.None; 2) Move your dialog from CellDoubleClick to DoubleClick, and begin edit on the currentcell afterwards.
private void gridControl1_DoubleClick(object sender, System.EventArgs e)
{
	MessageBox.Show("gridControl1_DoubleClick");
	this.gridControl1.CurrentCell.BeginEdit(true);
}
Default grid behavior lets you activate a cell for editing by pressing F2, so you can have an editing cell without double-clicking. But this may not be intuitive enough for your user. If you allow a single click to activate a cell, then it is tough to catch a double click. You can mark the time in of the single-click, and then if the embedded control gets another click within the DoubleClick time, then you could call it a double click, and perform your double click functions. This would take some work, but I expect it is doable.


RH Robert Hughes April 11, 2003 06:09 AM UTC

Thanks Clay.

Loader.
Live Chat Icon For mobile
Up arrow icon