XMLファイルの内容に応じて、実行時にプログラムは動的にテキストボックスとラベルを作成する必要があります。このコントロールをグループボックス内で次のように整理したいと思います。
[label1] [textbox1] [label2] [texbox2] [label3] [textbox]
[label4] [textbox4] [label5] [textbox5] [...]
など。
X
しかし、とのY
値を計算する方法がわかりません。私はいくつかの解決策を試しましたが、運がありません。1行にラベルとテキストボックスを配置する現在の実装の下:
[label1] [texbox1]
[labe2] [texbox2]
など。
//list the disiciplanas from XML file
//into combobox control.
for (int i = 0,
label_X = 20, label_Y = 20,
textbox_X = 74, textbox_Y = 20,
len = materias[0].ChildNodes.Count,
line = 0, tmp_pos = 20;
i < len;
i++,
tab_index++,
line++,
tmp_pos += 20
)
{
XmlNode materia = materias[0].ChildNodes[i];
Point label_position, textbox_position;
Label label = new Label();
TextBox textbox = new TextBox();
#if DEBUG_
if (line == 3)
{
label_X = 200 + tmp_pos;
label_Y = 25 + tmp_pos;
}
else
{
label_X += 10;
}
textbox_Y = label_Y;
#else
label_Y += 20;
textbox_Y = label_Y;
#endif
label.Text = "foo";
textbox.Size = new Size(48, 20);
textbox.Name = String.Format("nota{0}", fo.Name);
label_position = new Point();
label_position.X = label_X;
label_position.Y = label_Y;
textbox_position = new Point();
textbox_position.X = textbox_X;
textbox_position.Y = textbox_Y;
label.Location = label_position;
textbox.Location = textbox_position;
textbox.Left = 150;
textbox.TabIndex = tab_index;
notas_panel.Controls.Add(label);
notas_panel.Controls.Add(textbox);
}
これが明確であることを願っています。前もって感謝します