Marco
Marco

Reputation: 1025

How to connect a scrollbar to a panel in VC++?

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?

the image

Upvotes: 0

Views: 856

Answers (1)

Cody Gray
Cody Gray

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

Related Questions