21 August 2006

The ScrollableControl.AutoScroll (1st post)

Well, my application has a split panel control, in which panel 1 is fixed. My problem it that I am using user controls in the panel 2 pane, and the auto scroll property of panel 2 didn't work. I tried to look up the problem, but no go.

I then found out that my user control's content was set to autosize and docked to fill (tablelayout control) and the user control itself also was set to autosize.
When working with the user control, there doesn't seem to be any problem - the control resizes nicely.
The problem was when I added the usercontrols to the panel 2 of the split panel control - I docked them to fill also (!). Since I added the controls programatically, I didn't really have any knowledge about the problem until runtime.

The solution was quite simple: remove Dock.Fill inside the panel 2 pane. That way the panel knows about the minimum size of the added controls, and can set scrollbars as necessary. The controls still have their minimum size (set when designing the user control it self).

Now of course this might have been obvious for a lot of people, and when I come to think about it - it is so for me too ;)

No comments: