473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Radio Buttons in Menu

How can I put a set of Radio Buttons in a Menu? A bullet list of items where
selecting one automatically unselects the others.

Thanks
Apr 7 '06 #1
7 8691
Hi,

This functionality is not automatic. (Assuming you are referring to VS
2003, .NET 1.1)

Might be many ways to do it. Manually or Cleverly...

Here's my way : (The manual way)

--------------------------------------------

// This method is wired to Click events of all the MenuItems.
private void AllMnus_Click(object sender, System.EventArgs e)
{
MenuItem mnu = (MenuItem)sender;
Checker(mnu);
switch (mnu.Text)
{
case "One":
// Do your stuff
break;
case "Two":
// Do double the stuff
break;
case "Three":
// Do double the stuff
break;
}
}

// Iterates through the MenuItems, first unchecking all of them, and
then checking
// the relevant one.
private void Checker(MenuItem mnu)
{
foreach (MenuItem eachMnu in mnuTest.MenuItems)
{
eachMnu.Checked = false;
}
mnu.Checked = true;
}

--------------------------------------------

Explanation : Since the MenuItems have no Tag property (and
surprisingly, no Name property as well), we have to check the Text
property to find out which one was clicked. Then we just uncheck all of
them and check the proper one.

The Clever way :
An excellent alternative to doing it manually, might be to use Mick
Doherty's implementation. He uses an Extender component to add a Tag
property to MenuItems, and also a RadioGroup property which
accomplishes what we need. He should call it "Killing two birds with
one stone !" ;-)

This latter is the method I would recommend to you. Check out
<http://www.dotnetrix.pwp.blueyonder.co.uk/menus.html>

Regards,

Cerebrus.

Apr 8 '06 #2
You can use Checked menus..and use code to do the check/uncheck. Why radio
buttons? any reason?

VJ

"Martijn Mulder" <i@m> wrote in message
news:44***********************@news.wanadoo.nl...
How can I put a set of Radio Buttons in a Menu? A bullet list of items
where selecting one automatically unselects the others.

Thanks

Apr 8 '06 #3
I think Martijn means a RadioCheck style of Checked Menus. Not a Radio
button control. Atleast, that's what I assumed.

Regards,

Cerebrus.

Apr 8 '06 #4
>I think Martijn means a RadioCheck style of Checked Menus. Not a Radio
button control. Atleast, that's what I assumed.

Radio Buttons

A radio button looks very much like a check box except that it is shaped
like a circle rather than a box. A heavy dot within the circle indicates
that the radio button has been checked. The radio button has the window
style BS_RADIOBUTTON or BS_AUTORADIOBUTTON (...). groups of radio buttons
are conventionally used to indicate mutually exclusive options. Unlike check
boxes, radio buttons do not work as toggles - that is, when you click a
radio button a second time, its state remains unchanged. (Petzold,
Programming Windows 95)

I want to have a dropdown menu from the main menu filled with radio buttons,
like this:

File Edit View Options
o Black/White
o Color
o Sepia
o Acid

with one of the options on and all other options off until clicked.
Apr 8 '06 #5
Hi,

Did you see my response to your original post ?? It still sounds like
that's what you need.

Regards,

Cerebrus.

Apr 8 '06 #6
> Did you see my response to your original post ?? It still sounds like
that's what you need.


I am afraid you are right (thank you!). It's just that I expected it to be
build into C# and that it was only naming confusion that stopped me from
finding it. The System.Windows.Forms.ToolStripMenuItem does have a way to
set CheckBoxes on them, the square boxes that you can click on/of. The
Radiostyle that I need is not supported? mhhh...
Apr 8 '06 #7
Then the difference is not in language, but in the version of VS. I'm
still at VS 2003.

Apr 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: elhombrebala | last post by:
With this script I can force the user to select the checkbox befor continuing, but now I have a menu with lots of radio unputs and I woul like the user to select at least 2 of them; how can I check...
1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
3
by: TORQUE | last post by:
Hi How can I make a radio button create an action like enabling or disabling a delete button in a form? TIA TORQUE
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
2
by: Kusank | last post by:
I have 8 radio buttons that when they are selected will cause the drop down menu to change so that the sizes in the menu are correct, this works prefectly fine. But the issue I am having is once the...
4
by: RBrowning1958 | last post by:
Hello, Is there a way to group menu items so they act like radio buttons - that is when one is checked the others in the same group are unchecked - I'm looking for a property to group menu items...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.