开发者

How to show windows user control from another windows user control?

开发者 https://www.devze.com 2023-01-22 13:58 出处:网络
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

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 t开发者_运维百科he first one.

Please let me know the procedure to do this.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消