Distorted Controls
-
Hi. I have controls that are being loaded at run time. Initially when they are loaded they appear as they should be but when i minimize the windows form, and restore it, they add extra spaces between them. This curious behaviour is really threatening my sanity :mad: because i have gone through the source code (for the 100th time :doh: )and there appears to be no problem with it. Below is the source:
private void ShowQuestionsAndAnswers(ArrayList questions, ArrayList answers)
{groupBox2.Enabled = true; j = 0; for (int i = 0; i < questions.Count; i++) { tbp.Invalidate(); j = i; ArrayList ans = new ArrayList(); GroupBox gb = new GroupBox(); //gb.AutoSize = true; gb.Size = new Size(tbp.Width - 100, 150); tbp.Controls.Add(gb); // Adding the groupbox to the main table panel added during design time. TableLayoutPanel tbp2 = new TableLayoutPanel();// a panel for the controls inside the group box tbp2.ColumnCount = 1; // ensure that there is only one column in the panel inside the group box tbp2.AutoSize = true; gb.Controls.Add(tbp2);// add the panel in the group box // Make the controls (a label and four radiobuttons)i want to use ready Label newLabel = new Label(); //gb.Text = examsQuestions\[i\].ToString(); newLabel.Text = (i + 1).ToString() + ". " + questions\[i\].ToString(); newLabel.AutoSize = true; newLabel.BringToFront(); newLabel.Size = new Size(1000, 100); RadioButton rdb1 = new RadioButton(); rdb1.AutoSize = true; tbp2.SetRow(rdb1, 1); rdb1.Text = a\[0\].ToString(); rdb1.Click += new EventHandler(rdb\_Click); RadioButton rdb2 = new RadioButton(); rdb2.AutoSize = true; tbp2.SetRow(rdb2, 2); rdb2.Text = a\[1\].ToString(); ; rdb2.Click += new EventHandler(rdb\_Click); RadioButton rdb3 = new RadioButton(); rdb3.AutoSize = true; rdb3.Text = a\[2\].ToString(); ; rdb3.Click += new EventHandler(rdb\_Click); RadioButton rdb4 = n
-
Hi. I have controls that are being loaded at run time. Initially when they are loaded they appear as they should be but when i minimize the windows form, and restore it, they add extra spaces between them. This curious behaviour is really threatening my sanity :mad: because i have gone through the source code (for the 100th time :doh: )and there appears to be no problem with it. Below is the source:
private void ShowQuestionsAndAnswers(ArrayList questions, ArrayList answers)
{groupBox2.Enabled = true; j = 0; for (int i = 0; i < questions.Count; i++) { tbp.Invalidate(); j = i; ArrayList ans = new ArrayList(); GroupBox gb = new GroupBox(); //gb.AutoSize = true; gb.Size = new Size(tbp.Width - 100, 150); tbp.Controls.Add(gb); // Adding the groupbox to the main table panel added during design time. TableLayoutPanel tbp2 = new TableLayoutPanel();// a panel for the controls inside the group box tbp2.ColumnCount = 1; // ensure that there is only one column in the panel inside the group box tbp2.AutoSize = true; gb.Controls.Add(tbp2);// add the panel in the group box // Make the controls (a label and four radiobuttons)i want to use ready Label newLabel = new Label(); //gb.Text = examsQuestions\[i\].ToString(); newLabel.Text = (i + 1).ToString() + ". " + questions\[i\].ToString(); newLabel.AutoSize = true; newLabel.BringToFront(); newLabel.Size = new Size(1000, 100); RadioButton rdb1 = new RadioButton(); rdb1.AutoSize = true; tbp2.SetRow(rdb1, 1); rdb1.Text = a\[0\].ToString(); rdb1.Click += new EventHandler(rdb\_Click); RadioButton rdb2 = new RadioButton(); rdb2.AutoSize = true; tbp2.SetRow(rdb2, 2); rdb2.Text = a\[1\].ToString(); ; rdb2.Click += new EventHandler(rdb\_Click); RadioButton rdb3 = new RadioButton(); rdb3.AutoSize = true; rdb3.Text = a\[2\].ToString(); ; rdb3.Click += new EventHandler(rdb\_Click); RadioButton rdb4 = n
Do you handle an Resize event?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace