471,066 Members | 1,288 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

RadioButton doubleclick event...where did it go?

Help! A trawl through the archives couldn't shed any light on this, so is
there a way to handle DoubleClick events for RadioButtons in vb.NET? I'm
recoding a VB4 application, which used the double-click event on some
SSOption buttons and would like to duplicate this behaviour (for existing
users) in the vb.NET version. Using the cursor arrows to navigate through
radiobuttons contained in a groupbox inititates the click event for the
respective radiobutton whenever it receives the focus. In the VB4 version of
my application, using the cursor keys would select the appropriate
radiobutton, whilst pressing the Enter key when a radiobutton was selected
would cause the coding to select the appropriate routine (thus a user could
operate all aspects of the application using the keyboard only): if the mouse
was used instead, then double clicking the respective radiobutton would have
the same effect as the keyboard-only method.
The vb.NET on-line help mentions a RadioButton.DoubleClick event but
crypticly (to me at any rate) saying:
<<This member supports the .NET Framework infrastructure but is not intended
to be used directly from your code.
Public Shadows Event DoubleClick As Eventhandler >>
Erm, what does this mean? I guess it means that I can create an event
handler but I have no idea how to do this. Could some kind person provide
show me how it could be done? Many thanks in advance.
Nov 21 '05 #1
3 6335
I ran into this same problem, Googled, and found your post. After
digging around a bit using Reflector, I discovered that in the .NET
Framework 1.1, StandardClick is turned off for the RadioButton, and
therefore StandardDoubleClick is also off. They went out of their way
to make sure double-click is dead by clobbering the base class's
DoubleClick event with the "new" keyword in C# (the Shadows keyword in
VB.NET), and tacking on two attributes that ensure you can't find the
DoubleClick event in the designer or with Intellisense:
EditorBrowsable(EditorBrowsableState.Never) and Browsable(false).
Apparently they weren't aware that this is actually a useful feature:
http://blogs.msdn.com/oldnewthing/ar...04/447654.aspx

It appears the .NET Framework 2.0 fixes this by adding a
RadioButton.MouseDoubleClick event, but for those of us "unfortunate"
enough to be developing products on pre-2.0, we're on our own.

I came up with a solution to this in C#. Put the following code in the
form that contains the radio buttons and hook up all your RadioButtons'
Click events to radioButton_Click.

DateTime _lastClick = DateTime.MinValue;
object _lastControl = null;

private void radioButton_Click(object sender, EventArgs e)
{
// simulate a double-click since RadioButton disables it
DateTime clickTime = DateTime.Now;
if(_lastControl == sender)
{
TimeSpan ts = clickTime - _lastClick;
if(ts.TotalMilliseconds <= (double)SystemInformation.DoubleClickTime)
DoYourDoubleClickStuffHere();
}
_lastClick = clickTime;
_lastControl = sender;

// normal Click event stuff can go here
}

Hope this helps! Sorry it's not VB, but you should have no problem
porting it.

Oran

Nov 21 '05 #2
I ran into this same problem, Googled, and found your post. After
digging around a bit using Reflector, I discovered that in the .NET
Framework 1.1, StandardClick is turned off for the RadioButton, and
therefore StandardDoubleClick is also off. They went out of their way
to make sure double-click is dead by clobbering the base class's
DoubleClick event with the "new" keyword in C# (the Shadows keyword in
VB.NET), and tacking on two attributes that ensure you can't find the
DoubleClick event in the designer or with Intellisense:
EditorBrowsable(EditorBrowsableState.Never) and Browsable(false).
Apparently they weren't aware that this is actually a useful feature:
http://blogs.msdn.com/oldnewthing/ar...04/447654.aspx

It appears the .NET Framework 2.0 fixes this by adding a
RadioButton.MouseDoubleClick event, but for those of us "unfortunate"
enough to be developing products on pre-2.0, we're on our own.

I came up with a solution to this in C#. Put the following code in the
form that contains the radio buttons and hook up all your RadioButtons'
Click events to radioButton_Click.

DateTime _lastClick = DateTime.MinValue;
object _lastControl = null;

private void radioButton_Click(object sender, EventArgs e)
{
// simulate a double-click since RadioButton disables it
DateTime clickTime = DateTime.Now;
if(_lastControl == sender)
{
TimeSpan ts = clickTime - _lastClick;
if(ts.TotalMilliseconds <= (double)SystemInformation.DoubleClickTime)
DoYourDoubleClickStuffHere();
}
_lastClick = clickTime;
_lastControl = sender;

// normal Click event stuff can go here
}

Hope this helps! Sorry it's not VB, but you should have no problem
porting it.

Oran

Nov 21 '05 #3
Thanks for your comments: when I get some time I'll try 'porting' your code.
"od*******@gmail.com" wrote:
I ran into this same problem, Googled, and found your post. After
digging around a bit using Reflector, I discovered that in the .NET
Framework 1.1, StandardClick is turned off for the RadioButton, and
therefore StandardDoubleClick is also off. They went out of their way
to make sure double-click is dead by clobbering the base class's
DoubleClick event with the "new" keyword in C# (the Shadows keyword in
VB.NET), and tacking on two attributes that ensure you can't find the
DoubleClick event in the designer or with Intellisense:
EditorBrowsable(EditorBrowsableState.Never) and Browsable(false).
Apparently they weren't aware that this is actually a useful feature:
http://blogs.msdn.com/oldnewthing/ar...04/447654.aspx

It appears the .NET Framework 2.0 fixes this by adding a
RadioButton.MouseDoubleClick event, but for those of us "unfortunate"
enough to be developing products on pre-2.0, we're on our own.

I came up with a solution to this in C#. Put the following code in the
form that contains the radio buttons and hook up all your RadioButtons'
Click events to radioButton_Click.

DateTime _lastClick = DateTime.MinValue;
object _lastControl = null;

private void radioButton_Click(object sender, EventArgs e)
{
// simulate a double-click since RadioButton disables it
DateTime clickTime = DateTime.Now;
if(_lastControl == sender)
{
TimeSpan ts = clickTime - _lastClick;
if(ts.TotalMilliseconds <= (double)SystemInformation.DoubleClickTime)
DoYourDoubleClickStuffHere();
}
_lastClick = clickTime;
_lastControl = sender;

// normal Click event stuff can go here
}

Hope this helps! Sorry it's not VB, but you should have no problem
porting it.

Oran

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Lozzi | last post: by
1 post views Thread by Buddy Ackerman | last post: by
1 post views Thread by Duke | last post: by
4 posts views Thread by _DD | last post: by
1 post views Thread by =?Utf-8?B?R2lkaQ==?= | last post: by
1 post views Thread by Dom | last post: by
reply views Thread by Emma Middlebrook | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.