Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Hide/Show Controls into the Panel
 

Hide/Show Controls into the Panel

Hello Everyone,

I have an issue, I want to hide and then show some controls (like textboxes, panels, labels etc.) resides into the panel.

I am using VS 2008,

I can only remove/clear the controls like,

Me.MyPanel.Controls.Clear() OR Me.MyPanel.Controls.Remove(Me.txtName)

Its works fine but I want to Hide and then Show them without removing or clearing them.

Any help will be appreciable.

Thank You.



Regards Ashlesh,
Ashlesh Patel  Thursday, March 26, 2009 7:16 AM
Control.Visible = false; // Will hide the control

Control.Visible = true; // Will unhide the control

Thanks, A.m.a.L
A.m.a.L - aditi.com - Think Product  Thursday, March 26, 2009 7:49 AM
Hi,

Do you mean you want to hide specific controls? For example, the controlsare typed of button.

You can try the following. If the control in the panel is typed of button, set the visible to false.

private void button2_Click(object sender, EventArgs e)

{

foreach(Control contr in panel1.Controls)

{

if (contr is Button)

{

contr.Visible = false;

}

}

}


If i miunderstood you, or you have other questions, please feel free to tell me.

Best regards,
Ling Wang

Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Wednesday, April 01, 2009 12:57 PM
Control.Visible = false; // Will hide the control

Control.Visible = true; // Will unhide the control

Thanks, A.m.a.L
A.m.a.L - aditi.com - Think Product  Thursday, March 26, 2009 7:49 AM
Hi Amal,

Thanks for the reply.

I have tried your suggestion but I am not able to find the property like visible for the controls resides into the Panel. Like,

Me.panelMain.Controls.visible = True/False

I have two different use controls, 1. m_ucGeneral1 and 2. m_ucGeneral2

Now I wanted to show it simultaneously. Like, once I need to add m_ucGeneral1 and then m_ucGeneral2

So, what I am doing first I am clearing the panel using

Step - 1: Me.panelMain.Controls.Clear() then
Step - 2: Me.panelMain.Controls.Add(m_ucGeneral1)

Above same steps to show the m_ucGeneral2 control.


In the above case I dont want to clear and Add the control but only Hide the control.

So, Now please suggest me some way.


Thanks.




Regards Ashlesh,
Ashlesh Patel  Thursday, March 26, 2009 8:32 AM
Try

m_ucGeneral1.Visible = true;

m_ucGeneral2.Visible = false;

Thanks, A.m.a.L
A.m.a.L - aditi.com - Think Product  Thursday, March 26, 2009 9:10 AM
Hi Amal,


Thanks for the reply, but it does not work for me.

Thank You.

Regards Ashlesh,
Ashlesh Patel  Thursday, March 26, 2009 9:23 AM
Please provide me some inputs for this task.

Thanks.


Regards Ashlesh,
Ashlesh Patel  Friday, March 27, 2009 7:02 AM
Hi,

Do you mean you want to hide specific controls? For example, the controlsare typed of button.

You can try the following. If the control in the panel is typed of button, set the visible to false.

private void button2_Click(object sender, EventArgs e)

{

foreach(Control contr in panel1.Controls)

{

if (contr is Button)

{

contr.Visible = false;

}

}

}


If i miunderstood you, or you have other questions, please feel free to tell me.

Best regards,
Ling Wang

Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Wednesday, April 01, 2009 12:57 PM
Control.Visible = false; // Will hide the control

Control.Visible = true; // Will unhide the control
Devil vroom  Tuesday, April 14, 2009 7:26 AM

You can use google to search for other answers

Custom Search

More Threads

• Serialization logic for a custom XML serializer
• How to create the labels based on how many entries that i have in an SQL Server
• Windows Form Designer bug in causing an event handler to disappear, C# example
• scroll bar issue in MDI application
• Behavior, OnMouseUp event and the Point
• back color problem
• Panel control
• Extender provider and type converter
• How can I invoke the copy to clipboard functionality on the GridView
• switch between design-time mode and run-time mode