Link to home
Start Free TrialLog in
Avatar of Unimatrix_001
Unimatrix_001Flag for United Kingdom of Great Britain and Northern Ireland

asked on

WinForms - Scrolling a panel

Hello,

I'm creating my own scrollbar which should be able to be bound to any control and scroll it as necessary (i.e. if the preferred size is greater than the shown size). My problem is that I cannot change the .top property of the bound control when scrollbar is used because the control is often docked and has anchors.

1) Is there some way around this without modifying the .top property?
2) How does an autoscroll Panel manage it when the child components have docked properties set?

Thank you,
Uni
Avatar of Jarrod
Jarrod
Flag of South Africa image

you could set the dock property to none and resize controls to what they were before you change the docking ... then you can modify the top property.
Avatar of Unimatrix_001

ASKER

Hrm, perhaps there isn't another way around it.... Although I don't suppose you can specifically answer the second question?

Thanks very much,
Uni
ASKER CERTIFIED SOLUTION
Avatar of Jarrod
Jarrod
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use it like so:
var excludeControls = new List<string>();
            excludeControls.Add(button2.Name);
            excludeControls.Add(button3.Name);
            excludeControls.Add(button4.Name);
            excludeControls.Add(button5.Name);

            ScrollControls(10, 0, this, excludeControls);

Open in new window

Thank you. :)

I'm guessing that docking and anchoring just won't work - I can only guess that the Panel some something special internally... :(

Thanks,
Uni
:)
I'm not sure about the panel, however I would guess that they do something similar as all object eventually inheritfrom cwnd anyway :)

If you are really keen to find out you could use redgates reflector and decomile the windows.forms.controls dll - then find the panel and check the code out.