public void CreateMyPanel() { Panel panel1 = new Panel(); TextBox textBox1 = new TextBox(); Label label1 = new Label();
// Initialize the Panel control. panel1.Location = new Point(56,72); panel1.Size = new Size(264, 152); // Set the Borderstyle for the Panel to three-dimensional. panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
// Initialize the Label and TextBox controls. label1.Location = new Point(16,16); label1.Text = "label1"; label1.Size = new Size(104, 16); textBox1.Location = new Point(16,32); textBox1.Text = ""; textBox1.Size = new Size(152, 20);
// Add the Panel control to the form. this.Controls.Add(panel1); // Add the Label and TextBox controls to the Panel. panel1.Controls.Add(label1); panel1.Controls.Add(textBox1); } [C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
分類:[.NET]
こんにちは
下のような.NETマニュアルを参考に、
自分で作成したユーザコントロールを20個ほど
panel1.Controls.Add(userControl)
のように、新規にきれいに並べて配置・追加していこうとするのですが、
AutoScrollが発生してスクロールバーが表示されるように
なると、描画される配置がむちゃくちゃとなってしまいます。
原因が思い当たらないのですが、
なにかこのような経験をされた方アドバイス願います。
====
『Panel コントロールを作成し、 Label および TextBox を Panel に追加する例を次に示します。 Panel コントロールは、 Panel コントロールが位置する場所をフォーム上のほかのオブジェクトと区別するために 3D 境界線付きで表示されます。』
public void CreateMyPanel()
{
Panel panel1 = new Panel();
TextBox textBox1 = new TextBox();
Label label1 = new Label();
// Initialize the Panel control.
panel1.Location = new Point(56,72);
panel1.Size = new Size(264, 152);
// Set the Borderstyle for the Panel to three-dimensional.
panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
// Initialize the Label and TextBox controls.
label1.Location = new Point(16,16);
label1.Text = "label1";
label1.Size = new Size(104, 16);
textBox1.Location = new Point(16,32);
textBox1.Text = "";
textBox1.Size = new Size(152, 20);
// Add the Panel control to the form.
this.Controls.Add(panel1);
// Add the Label and TextBox controls to the Panel.
panel1.Controls.Add(label1);
panel1.Controls.Add(textBox1);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。