Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call the object of a control created on click event of a button into the click vent of another button?
    primarykey
    data
    text
    <p>I has added a panel on the click event of a button at runtime i.e. every time we will click on the button the panel will be called.</p> <pre><code>Panel p = new Panel(); p.Location = new Point(10, (childrenCount - 1) * 280); p.Width = 800; p.Height = 250; /****some code****/ this.Controls.Add(p); </code></pre> <p>Now i have dropped a new button on my form and i want that on the click event of the form the panel get removed. So how can i call object p of this panel class on the click event of this button.</p> <p><strong>And how to add background to a panel at runtime</strong> Here is the panel in which i want to add background</p> <pre><code>public void addchildbtn_Click_1(object sender, EventArgs e) { //Adds a child try { rmvchildclicklbl.Enabled = true; remvchildbtn.Enabled = true; no_childnumlbl.Text = (childrenCount).ToString(); childclmns clmn = new childclmns(); clmn.Location = new Point(100, 200); clmn.Name = "column" ; this.Controls.Add(clmn); childrenCount++; Panel p = new Panel(); p.Location = new Point(10, (childrenCount - 1) * 280); p.Width = 800; p.Height = 250; p.BorderStyle = BorderStyle.Fixed3D; p.ForeColor = Color.Black; p.BackColor = Color.WhiteSmoke; p.BackgroundImage = new Bitmap(@"image\baby.bmp"); p.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; // p.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); Label lblchild = new Label(); lblchild.BorderStyle = BorderStyle.Fixed3D; lblchild.Location = new Point(20, 50); lblchild.Size = new System.Drawing.Size(50, 20); lblchild.Text = "Child " + (childrenCount - 1); TextBox tName = new TextBox(); //TextBox for the name tName.BorderStyle = BorderStyle.Fixed3D; tName.Location = new Point(120, 50); tName.Size = new System.Drawing.Size(135, 60); tName.Text = ""; MonthCalendar calendar = new MonthCalendar(); //Calendar to choose the birth date calendar.Location = new Point(310, 40); ComboBox bloodGroup = new ComboBox(); //ComboBox for the blood group bloodGroup.Location = new Point(650, 50); bloodGroup.Size = new System.Drawing.Size(135, 60); for (Enum.Blood_Group l = Enum.Blood_Group.O_negative; l &lt;= Enum.Blood_Group.AB_positive; l++) { bloodGroup.Items.Add(l); } p.Controls.Add(lblchild); p.Controls.Add(tName); p.Controls.Add(calendar); p.Controls.Add(bloodGroup); this.Controls.Add(p); p.Name = "panel" + childrenCount; panels.Add(p); //Summit button location button1.Visible = true; int j=350, k= 300; k = k + ((childrenCount - 1) * 280); button1.Location = new Point(j, k); btnht= k.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload