Vote count:
0
I have a program which is some kind of tests. In this test, I have function AddQuestion
that adds one panel with question. To place these panels one by one, I have a variable loc
that saves location of next panel. First two Panel
's with questions adds correct, but next ones are located wrong(far away at the bottom). What can it be?
public void AddQuestion(int number, Question quest)
{
Panel p = new Panel();
p.Name = "panel" + (number);
p.Size = new Size(550, 400);
p.Location = new Point(40, loc);
p.BackColor = System.Drawing.Color.Bisque;
p.AutoScroll = true;
Panel pict_block = new Panel();
pict_block.Size = new Size(480, 200);
pict_block.Location = new Point(10, 10);
PictureBox pict = new PictureBox();
pict.Image = quest.image;
pict.Size = new Size(240, 180);
pict.SizeMode = PictureBoxSizeMode.StretchImage;
pict.Location = new Point(130, 1);
pict_block.Controls.Add(pict);
p.Controls.Add(pict_block);
Label number_text = new Label(); //номер питання
number_text.Text = "Питання № " + number ;
number_text.Font = new Font("Aria", 8, FontStyle.Bold);
number_text.AutoSize = false;
number_text.Location = new Point(400, 210);
p.Controls.Add(number_text);
Label q_text = new Label(); // текст питання
q_text.Text = quest.question_text;
q_text.Font = new Font("Aria", 9, FontStyle.Bold);
q_text.AutoSize = false;
q_text.Size = new Size(400, 50);
q_text.Location = new Point(5, 220);
p.Controls.Add(q_text);
int iter = q_text.Location.Y + 60;
if (CheckIfMuliple(number))
{
foreach (string key in quest.answers.Keys)
{
CheckBox rb = new CheckBox();
rb.Text = key;
rb.AutoSize = true;
rb.Size = new Size(300, 25);
rb.Location = new Point(q_text.Location.X + 15, iter);
iter += 30;
p.Controls.Add(rb);
}
}
else
{
foreach (string key in quest.answers.Keys)
{
RadioButton rb = new RadioButton();
rb.Text = key;
rb.Size = new Size(300, 25);
rb.AutoSize = true;
rb.Location = new Point(q_text.Location.X + 10, iter);
iter += 30;
p.Controls.Add(rb);
}
}
questions_panel.Controls.Add(p);
loc += 450;
}
asked 21 secs ago
Aucun commentaire:
Enregistrer un commentaire