473,796 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a limit on # of radio buttons

I have 8 radio buttons on my Windows form but I can only select up to the
first 4. If I click on any button beyond the 4th one and then come back into
the program again the 4th button is always checked instead of the 5th or 6th
etc. I followed the logic thru the debugger and can see where the 5th button
is progammatically checked but the window shows the 4th checked instead.
Does anyone have a clue as to what's going on here? All of the radio buttons
are in a group box.
Dave
Jul 17 '08
10 2211
Here is the form code. I noticed that there are some buttons in between the
radio buttons. Perhaps, that is what is causing the problem. Anyhow, I
deleted the group box and re-added the radio buttons and now it is working
properly. I don't know how it became faulty in the first place. I still
think there is a bug somewhere that caused it to become screwed up because I
designed this window in the same manner as all others using Visual Studio
2005. I did not override any behind the scene code. Thanks to everyone who
replied to this problem. If anyone knows what is faulty about the code
below, please let me know as I normally don't look at the behind the form
code.
Dave
#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.label1 = new System.Windows. Forms.Label();
this.label2 = new System.Windows. Forms.Label();
this.groupBox1 = new System.Windows. Forms.GroupBox( );
this.radioButto n3 = new System.Windows. Forms.RadioButt on();
this.radioButto n2 = new System.Windows. Forms.RadioButt on();
this.radioButto n1 = new System.Windows. Forms.RadioButt on();
this.button1 = new System.Windows. Forms.Button();
this.button2 = new System.Windows. Forms.Button();
this.radioButto n4 = new System.Windows. Forms.RadioButt on();
this.radioButto n5 = new System.Windows. Forms.RadioButt on();
this.radioButto n6 = new System.Windows. Forms.RadioButt on();
this.radioButto n7 = new System.Windows. Forms.RadioButt on();
this.radioButto n8 = new System.Windows. Forms.RadioButt on();
this.groupBox1. SuspendLayout() ;
this.SuspendLay out();
//
// label1
//
this.label1.Aut oSize = true;
this.label1.Fon t = new System.Drawing. Font("Microsoft Sans
Serif", 12.25F, System.Drawing. FontStyle.Bold,
System.Drawing. GraphicsUnit.Po int, ((byte)(0)));
this.label1.For eColor = System.Drawing. Color.Navy;
this.label1.Loc ation = new System.Drawing. Point(64, 9);
this.label1.Nam e = "label1";
this.label1.Siz e = new System.Drawing. Size(178, 20);
this.label1.Tab Index = 0;
this.label1.Tex t = "Date Conversion for";
//
// label2
//
this.label2.Aut oSize = true;
this.label2.Fon t = new System.Drawing. Font("Microsoft Sans
Serif", 12.25F, System.Drawing. FontStyle.Bold,
System.Drawing. GraphicsUnit.Po int, ((byte)(0)));
this.label2.For eColor = System.Drawing. Color.Navy;
this.label2.Loc ation = new System.Drawing. Point(68, 46);
this.label2.Nam e = "label2";
this.label2.Siz e = new System.Drawing. Size(59, 20);
this.label2.Tab Index = 1;
this.label2.Tex t = "label2";
//
// groupBox1
//
this.groupBox1. Controls.Add(th is.radioButton8 );
this.groupBox1. Controls.Add(th is.radioButton7 );
this.groupBox1. Controls.Add(th is.radioButton6 );
this.groupBox1. Controls.Add(th is.radioButton5 );
this.groupBox1. Controls.Add(th is.radioButton4 );
this.groupBox1. Controls.Add(th is.radioButton3 );
this.groupBox1. Controls.Add(th is.radioButton2 );
this.groupBox1. Controls.Add(th is.radioButton1 );
this.groupBox1. Location = new System.Drawing. Point(58, 69);
this.groupBox1. Name = "groupBox1" ;
this.groupBox1. Size = new System.Drawing. Size(200, 217);
this.groupBox1. TabIndex = 2;
this.groupBox1. TabStop = false;
this.groupBox1. Text = "Date display options";
//
// radioButton3
//
this.radioButto n3.AutoSize = true;
this.radioButto n3.Location = new System.Drawing. Point(18, 68);
this.radioButto n3.Name = "radioButto n3";
this.radioButto n3.Size = new System.Drawing. Size(96, 17);
this.radioButto n3.TabIndex = 2;
this.radioButto n3.Text = "Month dd, yyyy";
this.radioButto n3.UseVisualSty leBackColor = true;
//
// radioButton2
//
this.radioButto n2.AutoSize = true;
this.radioButto n2.Location = new System.Drawing. Point(18, 44);
this.radioButto n2.Name = "radioButto n2";
this.radioButto n2.Size = new System.Drawing. Size(83, 17);
this.radioButto n2.TabIndex = 1;
this.radioButto n2.Text = "mm/dd/yyyy";
this.radioButto n2.UseVisualSty leBackColor = true;
//
// radioButton1
//
this.radioButto n1.AutoSize = true;
this.radioButto n1.Checked = true;
this.radioButto n1.Location = new System.Drawing. Point(18, 20);
this.radioButto n1.Name = "radioButto n1";
this.radioButto n1.Size = new System.Drawing. Size(73, 17);
this.radioButto n1.TabIndex = 0;
this.radioButto n1.TabStop = true;
this.radioButto n1.Text = "mm/dd/yy";
this.radioButto n1.UseVisualSty leBackColor = true;
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(68, 293);
this.button1.Na me = "button1";
this.button1.Si ze = new System.Drawing. Size(75, 23);
this.button1.Ta bIndex = 3;
this.button1.Te xt = "Ok";
this.button1.Us eVisualStyleBac kColor = true;
this.button1.Cl ick += new System.EventHan dler(this.OnOk) ;
//
// button2
//
this.button2.Lo cation = new System.Drawing. Point(171, 292);
this.button2.Na me = "button2";
this.button2.Si ze = new System.Drawing. Size(75, 23);
this.button2.Ta bIndex = 4;
this.button2.Te xt = "Cancel";
this.button2.Us eVisualStyleBac kColor = true;
this.button2.Cl ick += new System.EventHan dler(this.OnCan cel);
//
// radioButton4
//
this.radioButto n4.AutoSize = true;
this.radioButto n4.Location = new System.Drawing. Point(18, 92);
this.radioButto n4.Name = "radioButto n4";
this.radioButto n4.Size = new System.Drawing. Size(47, 17);
this.radioButto n4.TabIndex = 8;
this.radioButto n4.TabStop = true;
this.radioButto n4.Text = "Year";
this.radioButto n4.UseVisualSty leBackColor = true;
//
// radioButton5
//
this.radioButto n5.AutoSize = true;
this.radioButto n5.Location = new System.Drawing. Point(18, 116);
this.radioButto n5.Name = "radioButto n5";
this.radioButto n5.Size = new System.Drawing. Size(55, 17);
this.radioButto n5.TabIndex = 9;
this.radioButto n5.TabStop = true;
this.radioButto n5.Text = "Month";
this.radioButto n5.UseVisualSty leBackColor = true;
//
// radioButton6
//
this.radioButto n6.AutoSize = true;
this.radioButto n6.Location = new System.Drawing. Point(18, 141);
this.radioButto n6.Name = "radioButto n6";
this.radioButto n6.Size = new System.Drawing. Size(44, 17);
this.radioButto n6.TabIndex = 10;
this.radioButto n6.TabStop = true;
this.radioButto n6.Text = "Day";
this.radioButto n6.UseVisualSty leBackColor = true;
//
// radioButton7
//
this.radioButto n7.AutoSize = true;
this.radioButto n7.Location = new System.Drawing. Point(18, 165);
this.radioButto n7.Name = "radioButto n7";
this.radioButto n7.Size = new System.Drawing. Size(84, 17);
this.radioButto n7.TabIndex = 11;
this.radioButto n7.TabStop = true;
this.radioButto n7.Text = "Month name";
this.radioButto n7.UseVisualSty leBackColor = true;
//
// radioButton8
//
this.radioButto n8.AutoSize = true;
this.radioButto n8.Location = new System.Drawing. Point(18, 189);
this.radioButto n8.Name = "radioButto n8";
this.radioButto n8.Size = new System.Drawing. Size(73, 17);
this.radioButto n8.TabIndex = 12;
this.radioButto n8.TabStop = true;
this.radioButto n8.Text = "Day name";
this.radioButto n8.UseVisualSty leBackColor = true;
//
// convertdate
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(284, 328);
this.Controls.A dd(this.button2 );
this.Controls.A dd(this.button1 );
this.Controls.A dd(this.groupBo x1);
this.Controls.A dd(this.label2) ;
this.Controls.A dd(this.label1) ;
this.Name = "convertdat e";
this.Text = "convertdat e";
this.groupBox1. ResumeLayout(fa lse);
this.groupBox1. PerformLayout() ;
this.ResumeLayo ut(false);
this.PerformLay out();

}

#endregion

private System.Windows. Forms.Label label1;
private System.Windows. Forms.Label label2;
private System.Windows. Forms.GroupBox groupBox1;
private System.Windows. Forms.RadioButt on radioButton3;
private System.Windows. Forms.RadioButt on radioButton2;
private System.Windows. Forms.RadioButt on radioButton1;
private System.Windows. Forms.Button button1;
private System.Windows. Forms.Button button2;
private System.Windows. Forms.RadioButt on radioButton4;
private System.Windows. Forms.RadioButt on radioButton8;
private System.Windows. Forms.RadioButt on radioButton7;
private System.Windows. Forms.RadioButt on radioButton6;
private System.Windows. Forms.RadioButt on radioButton5;

Dave

"Michael D. Ober" wrote:
"Parrot" <Pa****@discuss ions.microsoft. comwrote in message
news:26******** *************** ***********@mic rosoft.com...
I am pasting the entire code for the C# program below. As I mentioned
earlier I can follow the logic in debug mode and I can see where
radiobutton5
is set to checked but it still shows radiobutton4 with the check when the
window is displayed.

namespace WindowsApplicat ion1
{
public partial class convertdate : Form
{

public string xdateformat;

public convertdate(str ing field, string dateformat)
{
InitializeCompo nent();
label2.Text = field;

xdateformat = dateformat;

if (dateformat.Com pareTo("1") == 0)
radioButton1.Ch ecked = true;
else
if (dateformat.Com pareTo("101") == 0)
{
radioButton2.Ch ecked = true;
radioButton1.Ch ecked = false;
}
else
if (dateformat.Com pareTo("107") == 0)
{
radioButton3.Ch ecked = true;
radioButton1.Ch ecked = false;
}
else
if (dateformat.Com pareTo("year") == 0)
{
radioButton4.Ch ecked = true;
radioButton1.Ch ecked = false;
}
else
if (dateformat.Com pareTo("month") == 0)
{
radioButton5.Ch ecked = true;
radioButton1.Ch ecked = false;

}
else
if (dateformat.Com pareTo("day") == 0)
{
radioButton6.Ch ecked = true;
radioButton1.Ch ecked = false;

}
else
if (dateformat.Com pareTo("monthna me") == 0)
{
radioButton7.Ch ecked = true;
radioButton1.Ch ecked = false;
}
else
if (dateformat.Com pareTo("dayname ") ==
0)
{
radioButton8.Ch ecked = true;
radioButton1.Ch ecked = false;
}

}

private void OnCancel(object sender, EventArgs e)
{
this.Close();
}

private void OnOk(object sender, EventArgs e)
{
if (radioButton1.C hecked)
xdateformat = "1";
else
if (radioButton2.C hecked)
xdateformat = "101";
else
if (radioButton3.C hecked)
xdateformat = "107";
else
if (radioButton4.C hecked)
xdateformat = "year";
else
if (radioButton5.C hecked)
xdateformat = "month";
else
if (radioButton6.C hecked)
xdateformat = "day";
else
if (radioButton7.C hecked)
xdateformat = "monthname" ;
else
if (radioButton8.C hecked)
xdateformat = "dayname";
this.Close();
}
}
}

"Peter Duniho" wrote:
On Thu, 17 Jul 2008 18:26:02 -0700, Parrot
<Pa****@discuss ions.microsoft. comwrote:

[...]
Simply put. the system will not properly handle beyond 3 radio buttons
in the
same group. Such a simple program and I am spinning my wheels. It
couldn't
be a bug could it?

Surely it's a bug. But it's probably in your code.

Unfortunately, you haven't shared that with us. So it's not possible for
us to point it out.

If you can post a concise-but-complete code sample that reliably
reproduces the problem, it should be possible to provide a more complete
answer.

Pete

We need the code behind the form. That's where the grouping of radio
buttons is controlled. You have a grouping error.

Mike.
Jul 18 '08 #11

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

Similar topics

1
6165
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there are no instructions on how to make checkboxes and radio buttons required. I've tried adding these to my form, but I'm having no luck. Anyone know how to add radio buttons and checkboxes using the existing code mentioned on the url? Thank you!
2
3156
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
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
5431
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and I want to be able to retrieve the selected value from each of the sets of radio buttons.The names of each group of radio buttons is set by the database and I don't know how to retrieve the values because I don't know the names of these radio...
2
11983
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...
1
6892
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and grandtotal the costs ready for the selected items to be inserted back to the database. I did something like this before with Checkboxes, but Radio button have to be named the same to maintain their groupings.
10
6106
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
2
5894
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
4
2520
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see all twelve. User2 would see buttons 1-3,10-12 and NOT any others, and so on. Since there are several buttons on the page (each one would run a report for them), is there a way to - in an onclick event for each of the buttons - to...
0
9673
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
9525
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
10452
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
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...
1
10169
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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...
1
7546
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
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();...
3
2924
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.