M
Mark Erikson
I'd like to get double-click notification with a TreeView. I've tried
deriving from TreeView and overriding OnClick, as shown in a Microsoft
sample
(http://samples.gotdotnet.com/quickstart/compactframework/doc/btndclick.aspx),
but nothing seems to happen. I've tried setting a breakpoint on the
first line of OnClick, but it doesn't get hit at all. Here's my
current code:
public class TreeViewEx : TreeView
{
private int previousClick = SystemInformation.DoubleClickTime + 1;
public event EventHandler DoubleClick;
protected override void OnClick(EventArgs e)
{
int now = System.Environment.TickCount;
if (now - previousClick <= SystemInformation.DoubleClickTime)
{
MessageBox.Show("Double clicked");
if (DoubleClick != null)
{
DoubleClick(this, EventArgs.Empty);
}
}
previousClick = now;
base.OnClick(e);
}
protected virtual void OnDoubleClick(EventArgs e)
{
if (DoubleClick != null)
{
DoubleClick(this, e);
}
}
}
I get the feeling I'm missing something simple and obvious. Anyone
have any ideas?
Thanks!
Mark Erikson
http://www.isquaredsoftware.com
deriving from TreeView and overriding OnClick, as shown in a Microsoft
sample
(http://samples.gotdotnet.com/quickstart/compactframework/doc/btndclick.aspx),
but nothing seems to happen. I've tried setting a breakpoint on the
first line of OnClick, but it doesn't get hit at all. Here's my
current code:
public class TreeViewEx : TreeView
{
private int previousClick = SystemInformation.DoubleClickTime + 1;
public event EventHandler DoubleClick;
protected override void OnClick(EventArgs e)
{
int now = System.Environment.TickCount;
if (now - previousClick <= SystemInformation.DoubleClickTime)
{
MessageBox.Show("Double clicked");
if (DoubleClick != null)
{
DoubleClick(this, EventArgs.Empty);
}
}
previousClick = now;
base.OnClick(e);
}
protected virtual void OnDoubleClick(EventArgs e)
{
if (DoubleClick != null)
{
DoubleClick(this, e);
}
}
}
I get the feeling I'm missing something simple and obvious. Anyone
have any ideas?
Thanks!
Mark Erikson
http://www.isquaredsoftware.com