Unimatrix_001
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
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
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.
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
Thanks very much,
Uni
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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);
ASKER
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 guessing that docking and anchoring just won't work - I can only guess that the Panel some something special internally... :(
Thanks,
Uni
ASKER
:)
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.
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.