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 InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton7 = new System.Windows.Forms.RadioButton();
this.radioButton8 = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans
Serif", 12.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.Navy;
this.label1.Location = new System.Drawing.Point(64, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(178, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Date Conversion for";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans
Serif", 12.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Navy;
this.label2.Location = new System.Drawing.Point(68, 46);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 20);
this.label2.TabIndex = 1;
this.label2.Text = "label2";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton8);
this.groupBox1.Controls.Add(this.radioButton7);
this.groupBox1.Controls.Add(this.radioButton6);
this.groupBox1.Controls.Add(this.radioButton5);
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.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.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(18, 68);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(96, 17);
this.radioButton3.TabIndex = 2;
this.radioButton3.Text = "Month dd, yyyy";
this.radioButton3.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(18, 44);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(83, 17);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "mm/dd/yyyy";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(18, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(73, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "mm/dd/yy";
this.radioButton1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(68, 293);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 3;
this.button1.Text = "Ok";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.OnOk);
//
// button2
//
this.button2.Location = new System.Drawing.Point(171, 292);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 4;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.OnCancel);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(18, 92);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(47, 17);
this.radioButton4.TabIndex = 8;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "Year";
this.radioButton4.UseVisualStyleBackColor = true;
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Location = new System.Drawing.Point(18, 116);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(55, 17);
this.radioButton5.TabIndex = 9;
this.radioButton5.TabStop = true;
this.radioButton5.Text = "Month";
this.radioButton5.UseVisualStyleBackColor = true;
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Location = new System.Drawing.Point(18, 141);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(44, 17);
this.radioButton6.TabIndex = 10;
this.radioButton6.TabStop = true;
this.radioButton6.Text = "Day";
this.radioButton6.UseVisualStyleBackColor = true;
//
// radioButton7
//
this.radioButton7.AutoSize = true;
this.radioButton7.Location = new System.Drawing.Point(18, 165);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(84, 17);
this.radioButton7.TabIndex = 11;
this.radioButton7.TabStop = true;
this.radioButton7.Text = "Month name";
this.radioButton7.UseVisualStyleBackColor = true;
//
// radioButton8
//
this.radioButton8.AutoSize = true;
this.radioButton8.Location = new System.Drawing.Point(18, 189);
this.radioButton8.Name = "radioButton8";
this.radioButton8.Size = new System.Drawing.Size(73, 17);
this.radioButton8.TabIndex = 12;
this.radioButton8.TabStop = true;
this.radioButton8.Text = "Day name";
this.radioButton8.UseVisualStyleBackColor = true;
//
// convertdate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 328);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "convertdate";
this.Text = "convertdate";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.RadioButton radioButton8;
private System.Windows.Forms.RadioButton radioButton7;
private System.Windows.Forms.RadioButton radioButton6;
private System.Windows.Forms.RadioButton radioButton5;
Dave
Michael D. Ober said:
Parrot said:
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 WindowsApplication1
{
public partial class convertdate : Form
{
public string xdateformat;
public convertdate(string field, string dateformat)
{
InitializeComponent();
label2.Text = field;
xdateformat = dateformat;
if (dateformat.CompareTo("1") == 0)
radioButton1.Checked = true;
else
if (dateformat.CompareTo("101") == 0)
{
radioButton2.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("107") == 0)
{
radioButton3.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("year") == 0)
{
radioButton4.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("month") == 0)
{
radioButton5.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("day") == 0)
{
radioButton6.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("monthname") == 0)
{
radioButton7.Checked = true;
radioButton1.Checked = false;
}
else
if (dateformat.CompareTo("dayname") ==
0)
{
radioButton8.Checked = true;
radioButton1.Checked = false;
}
}
private void OnCancel(object sender, EventArgs e)
{
this.Close();
}
private void OnOk(object sender, EventArgs e)
{
if (radioButton1.Checked)
xdateformat = "1";
else
if (radioButton2.Checked)
xdateformat = "101";
else
if (radioButton3.Checked)
xdateformat = "107";
else
if (radioButton4.Checked)
xdateformat = "year";
else
if (radioButton5.Checked)
xdateformat = "month";
else
if (radioButton6.Checked)
xdateformat = "day";
else
if (radioButton7.Checked)
xdateformat = "monthname";
else
if (radioButton8.Checked)
xdateformat = "dayname";
this.Close();
}
}
}
Peter Duniho said:
On Thu, 17 Jul 2008 18:26:02 -0700, Parrot
[...]
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.