Reputation: 1269
I have a windows form and a flow layout panel on the form. I am dynamically adding text boxes to the flow layout panel and setting the auto scroll to true for the flow lay out panel has the dynamic text boxes display greatly inaccurate. Is it possible to have ONE vertical scroll bar that will scroll the windows form as well as the data on the flow layout panel?
I have tried setting the AutoScroll property to True, and WrapContents to False, but that only adds the scroll bar for the flow layout panel not the whole form. I also tried to code to add a scrollbar, which is succesful but that will only scroll the form not the flow layout panel. Is there a way to use 1 scroll bar docked on the right side of the form to scroll the form and the flow layout panel?
The code I used to create the scroll bar is as follows.
VScrollBar scrollbar1 = new VScrollBar();
scrollbar1.Dock = DockStyle.Right;
Controls.Add(scrollbar1);
EDIT #1 ---- I also tried to add the scroll bar to both the form as well as the form layout panel like so and this caused the scroll bar to not even display.
VScrollBar scrollbar1 = new VScrollBar();
scrollbar1.Dock = DockStyle.Right;
Controls.Add(scrollbar1);
flowlayoutpanel1.Controls.Add(scrollbar1);
EDIT #2 ---- I want ONE scroll bar that is able to scroll the entire windows form, for both the windows form and the flow layout panel.
EDIT #3 ----- The "possible answer" posted above is not applicable for my question as it only shows how to add the vertical scroll bar to a panel not ONE scroll bar to control both the form itself and a panel.
Upvotes: 2
Views: 1247
Reputation: 283
Make sure that your control's settings are as follows:
FlowLayoutPanel
AutoSize = true
AutoScroll = false
WrapContents = true
Anchor = Top (required) | Left (optional)
MainForm
AutoScroll = true
Based on our chat these should be the settings that get you going!
Upvotes: 1