views:

22

answers:

2

Hi, can anyone tell me how to achieve the below scenario: I have a windows form in which a windows user control(first user control) is present. On click of the button in the first windows user control I want to show another windows user control(second) and hide the first one.

Please let me know the procedure to do this.

Thanks in Advance

A: 

Declare & Raise an event from the first user control to the Windows Form. The windows form will then hide the first one and show the second user control

Or.

On click of first user controls button Hide the user control. the windows form can then listen for the visibilechange event and Show the second user control

SysAdmin
A: 

You can do 2 things here.

Create 2 controls at design time, userControl1 and userControl2. Set the Visible property to true,false respectively. In the OnClickevent for your button, set to false,true for Visible.

Create 1 control at design time. In the OnClick event, create a second control dynamically, and add it to the form, and hide the first one.

Which one you use, will depend on your exact situation.

jasper