Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey,
can any body tell me, how to implement a panel control on winform using c#.NET..??
and also how to make visible on a particular event...??
Posted

 
Share this answer
 
Comments
Espen Harlinn 8-Feb-12 10:49am    
5'ed!
Abhinav S 8-Feb-12 12:37pm    
Thank you Espen.
Dynamic Creation Of Panel
C#
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);
 }


Now Suppose You Have A Button On Your Form And On The Click Event You Want To Show The Panel Then,
C#
private void btnButton1_Click(object sender, EventArgs e)
{
    panel1.visible = true;
}


Accept This Answer If It Has Helped You
 
Share this answer
 
Either drag it onto your form from the toolbox in the designer, and size and place it appropriately, or:
C#
private Panel myPanel;
...
   // Form load event, or constructor
   myPanel = new Panel();
   Controls.Add(myPanel);
   myPanel.Controls.Add(new Button());  //Just for example
You can make it visible or invisible via the Visible property. If you make a panel Visible false, all it's contained controls will disappear too.
 
Share this answer
 
Comments
[no name] 8-Feb-12 3:21am    
thankx buddy for helping me out...
'Panel' control is available in control toolbox of Visual Studio. Add the same control(Panel) to your form , after that you can add control like Button,TextBox etc. to this panel control.

Suppose you want to make it visible or invisible on click event of button you can use this code

C#
//for hiding the visible panel
panel1.Visible = false;

//for displaying the hidden panel
panel1.Visible = true;


hope this will help you
 
Share this answer
 
Comments
[no name] 8-Feb-12 3:18am    
thank you buddy...
thank you all...my problem is solved....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900