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.