Hi Kulabhishek,
I can reproduce the problems. However, the result of mine is a bit different for you. I don't know if the sequence of the Panels is the same with you. In my splitContainer control, panel1 is in the left, and panel2 is in the right. The test result is the resize event of the panel2 is always getting called first.
Try to control the fired sequence of these two events is really hard. Additionally, these two events may get fired many times during the resizing period. So I think a better way to get around this is handling the resize event of the Form instead.
Please try the following code, it works well on my side.
| publicpartialclassForm1:Form |
| { |
| PointoldFormLocation; |
| Directiondir; |
|
| enumDirection |
| { |
| Left, |
| Right |
| } |
| publicForm1() |
| { |
| InitializeComponent(); |
| this.splitContainer1.IsSplitterFixed=true; |
| oldFormLocation=this.Location; |
| this.Resize+=newEventHandler(Form1_Resize); |
| } |
|
| voidForm1_Resize(objectsender,EventArgse) |
| { |
| if(this.Location.X!=oldFormLocation.X) |
| { |
| dir=Direction.Left; |
| } |
| else |
| { |
| dir=Direction.Right; |
| } |
| if(dir==Direction.Left) |
| { |
| this.splitContainer1.FixedPanel=FixedPanel.Panel2; |
| } |
| if(dir==Direction.Right) |
| { |
| this.splitContainer1.FixedPanel=FixedPanel.Panel1; |
| } |
| this.oldFormLocation=this.Location; |
| } |
| } |
Note that panel1 is in the left, and panel2 is in the right.
If you have any problem, please feel free to let me know.
Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.