473,799 Members | 2,764 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 8721
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(o bject sender, System.EventArg s e)
{
MenuItem mnu = (MenuItem)sende r;
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(MenuIte m mnu)
{
foreach (MenuItem eachMnu in mnuTest.MenuIte ms)
{
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.p wp.blueyonder.c o.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.n l...
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_AUTORADIOBUT TON (...). 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.ToolStrip MenuItem 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
2304
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
6948
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: TRACE0("Warning: skipping non-radio button in group.\n"); (Copyright
4
3282
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
3295
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
11985
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 run time but with fixed radio buttons (like from an array). I need to create radio buttons based...
3
3065
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
5895
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 buttons and labels invisible and
2
1229
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 the popup to load once they select the size. Is there any one that can help me with this part?
4
6840
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
9687
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4139
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
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.