View previous topic :: View next topic |
Author |
Message |
donetteh
Joined: 23 Jun 2006 Posts: 3
|
Posted: Fri Jun 23, 2006 2:12 pm Post subject: Cell Editor only on Cell Click not Double Click |
|
|
Hi,
I am using Programmatic binding and a Cell Editor. I would like to only use the Cell Editor if the user Clicks the cell, and handle the Double Click myself with a different action. I cannot figure out how to do this. Can you pls give advice on the best way to go about this.
Thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Jun 24, 2006 12:45 am Post subject: |
|
|
The CellEditor is actually activated by default in the MouseDown event. This is because the Click event is not fired until the user releases the mouse button. The MouseDown event however will be received when the user clicks or double clicks - meaning it will be difficult to distinguish the conditions. There are a couple of options if you want to change this.
The first option is to set VirtualTree.SelectBeforeEdit to true. This requires that the user first selects a row before editing cells in it. This would allow you to trap double clicks/and or clicks without interaction with the CellEditor.
The second option is to change the behaviour by creating a custom CellWidget class and overriding the OnMouseDown and OnClick methods. See the Custom Widget sample project for an example of how to do this. The following is a little bit of a hack but it will work:
Code: | MouseEventArgs mouseDownArgs;
public override void OnMouseDown(MouseEventArgs e)
{
mouseDownArgs = e;
RowWidget.OnMouseDown(e);
}
public override void OnClick(EventArgs e)
{
base.OnMouseDown (mouseDownArgs);
} |
This basically stops the cell mouse down from activating the edit and changes OnClick to do what OnMouseDown used to.
Rather than calling base.OnMouseDown from OnClick it would be cleaner simply to call Tree.EditWidget = this; However the EditWidget property is protected and can't be accessed directly from the derived CellWidget class. You could add an internal property to the derived VirtualTree class to allow access to this property and then call that. _________________ Infralution Support |
|
Back to top |
|
|
|