473,520 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8705
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
2285
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 it? <form name=formulario> <INPUT type=checkbox name=casilla> <INPUT type=button value="Salir" onclick="Goingout()"> </form>
1
6890
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 combination of them all. What worked for me was the following: 1. Put a Break Point in MFC source file DLGDATA.CPP on line 338 which is:...
4
3254
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> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
6
3259
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 The problem i am facing is that i do not know how many yes/no radio groups will be generated
2
11929
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 them each in a GroupBox. All the examples I saw from the books or from the web show me how to add static radio buttons at design, or dynamically at...
3
3046
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
5878
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 the form by changing the visible state of the radio buttons and labels utilising back and next buttons. E.g. Next button makes current radio...
2
1182
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 drop down menu changes I awnt the drop down menu to create different popups depending on which size the click on inside the dropdown menu, and i want...
4
6830
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 but can't see it. Delphi's VCL has GroupIndex for example. Ta Ray
0
7324
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7464
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7627
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5765
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5155
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3295
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1678
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
529
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.