I have a SplitContainer I want to catch the Panel2 collapsing and expanding events.
Any idea how to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Posting this for others that might be hunting for the same answer as I was.
Unfortunately SplitContainer doesn’t offer any direct events for the collapsed events. What I have found useful is to monitor the SizeChanged and/or ClientSizeChanged events of the OPPOSITE panel to the one you’re collapsing.
Meaning, if I am interested in monitoring collapses of Panel2, I would subscribe to ClientSizeChanged events for Panel1.
In practice I would recommend monitoring the ClientSizeChanged for both panels of the SplitContainer to guarantee you don’t miss any initialization or direct splitter movements.
In the below example I have a toggle button (btnToggle) that I want the Checked state to follow the visibility of Panel2 in the SplitContainer: