Hi Experts,
I have develop a windows form with panel inside the groupbox.
With the button click event generate 100 label box dynamically with in panel (scroll bar).
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Location = new System.Drawing.Point(35, 26);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(237, 108);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "LabelTest";
//
// button1
//
this.button1.Location = new System.Drawing.Point(35, 153);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.AutoSize = true;
this.panel1.Location = new System.Drawing.Point(7, 20);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(224, 82);
this.panel1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(370, 255);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
Button Click
private void button1_Click(object sender, EventArgs e)
{
int pt = 5;
for (int i = 1; i <= 10; i++)
{
Label lbl = new Label();
lbl.Name = "lSector" + i.ToString();
lbl.Text = "lSector" + i.ToString();
lbl.AutoSize = true;
lbl.Location = new System.Drawing.Point(10, pt);
lbl.Size = new System.Drawing.Size(115, 14);
lbl.Visible = true;
panel1.Controls.Add(lbl);
panel1.AutoSize = true;
panel1.AutoScroll = true;
pt = pt + 10;
}
groupBox1.Controls.Add(panel1);
}
But I could not able to produce the scroll bar.
Please help me out.
Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/