By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Multiple display of panel on the click of a buttton

P: 3
Hi

I have a panel control in Winform, on the panel I have few controls like datecontrol, textbox,combobox. When I click on a button callled add I want to display the panel. I used the following code.Its working fine.
Expand|Select|Wrap|Line Numbers
  1. private void add_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             panel3.Visible = true;
  5.  
  6.         }
  7.  
Now if I click the Add button again I want the panel to appear one more time on the form.I mean mutliple click to add button should display the same panel serveral times. How do I do this.
Feb 11 '09 #1
Share this Question
Share on Google+
1 Reply


tlhintoq
Expert 2.5K+
P: 3,525
You will have to create a new panel each time you click the button, instead of just showing a hidden panel created at design time. Of course you will have to work out the location of the new panel so it doesn't wind up under pre-existing controls.

Expand|Select|Wrap|Line Numbers
  1.             Panel AnotherPanel = new Panel();
  2.             AnotherPanel.Width = 100;
  3.             AnotherPanel.Height = 100;
  4.             AnotherPanel.BackColor = Color.Red;
  5.             AnotherPanel.Location = new Point (50,50);
  6.             this.Controls.Add(AnotherPanel);
  7.             AnotherPanel.Show();
  8.  
Feb 11 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.