Re: radio button question
- From: "Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 11 Oct 2005 12:34:42 -0700
"Gregory Khrapunovich" <greg@xxxxxxxxx> wrote in message
news:u7MZGOoyFHA.1256@xxxxxxxxxxxxxxxxxxxxxxx
>I have a form that should react to arrow keys (up/down/left/right) in a
> special way. I created a KeyDown event handler and it works with one
> exception: when any radio button is in focus, it will capture the event
> before my handler and will change its state. My handler will not be
> called.
> Setting KeyPreview doesn't help.
>
> I found a workaround by forcing the focus to a different control. Is there
> a
> better way?
>
> Thank you.
> Gregory
Man... things sure take their time getting answered around here! People jump
on the "easy" stuff but leave everyone else hanging (just a general
observation when comparing anything.net to anything.com)
Radio buttons can be tricky. The functionality they expose hasn't changed
since they were first introduced (probably Windows 1.0 or something). As
soon as one gets focus, it sets itself true. Whether you want it or not.
That's how they've always worked. In VB6, the focus wouldn't go to a radio
button that's set = False if the user's using the Tab key. Arrows will set
focus to an option that's false.... which causes it to be set = true. You
can also get unexpected behavior while disabling or re-enabling them (in VB6
anyway). Assuming you use some kind of loop to do the enable/disable work,
keep in mind that, if you disable the option that's set = True, the next
option in the tab order will get focus.... which sets it = True. It was
maddening until I figured out that the easiest way to cure that behavior was
to place all option buttons in a frame (container control... not sure what a
..Net frame does) and disable the frame before manipulating the
enabled/disabled states and re-enable the frame when it's all over.
If you absolutely need to have the option buttons work the way you want, you
can always build your own (easy in VB5/6) and show their state using
characters from the Marlett font.
--
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
.
- References:
- radio button question
- From: Gregory Khrapunovich
- radio button question
- Prev by Date: Re: howdo i have a right click cause a tree node to become selected?
- Next by Date: Windows Forms - Datagrid sort by hidden column
- Previous by thread: radio button question
- Next by thread: TextBox Text Region
- Index(es):