Reputation: 1025
I need to create a panel to display a long radiobutton form with a scrollbar in VC++ (like the following picture). Since I have hundreds of radio buttons, I cannot show all at once. I need to use a scrollbar to control the current position of the radiobutton form. How I can make the scrollbar connect to the panel to do this task?
Upvotes: 0
Views: 856
Reputation: 244732
Writing code to synchronize a separate scroll bar control with a Panel
control is possible, but it's definitely the hard way of doing things.
Instead, consider setting the AutoScroll
property of your Panel
control to true
. When this property is enabled and the control has a virtual size larger than its visible boundaries, a scroll bar will automatically appear. Much easier.
You can set this property either in the designer, or through code in your form's constructor:
myPanel.AutoScroll = true;
Upvotes: 1