Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SplitterDistance changes as size of control changes

I have a SplitContainer control on my form. It's docked to the form. And I set the SplitterDistance from code when the form loads.

This works fine except that the SplitterDistance changes when I resize the form. For example, when I make the form wider, the SplitterDistances seems to become larger so that it retains about the same percentage of width of the parent.

I don't want this. I want the distance between the splitter bar and the left of the control to stay the same as the window is resized. However, I don't want to set IsSplitterFixed = true because I still want to allow the user to change it.

like image 940
Jonathan Wood Avatar asked Oct 22 '25 13:10

Jonathan Wood


1 Answers

You can set FixedPanel property to the panel which you want to remain the same size when the container is resized. You can do it using designer, or using code:

this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
like image 96
Reza Aghaei Avatar answered Oct 24 '25 02:10

Reza Aghaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!