Trying to add scrollbar

Sinlin

New member
Joined
Nov 14, 2016
Messages
3
Programming Experience
Beginner
I am writing a program in Visual Studio 15 in C#.

I have a window with some buttons and a frame.
Clicking on the buttons loads separate windows into the frame.

I would like the windows that load into the frame to have scrollbars, as some of them don't fit inside the frame they are called into.

Would I add the scrollbars to the frame, or to the windows I am calling into the frame?

Also, I can't figure out how to actually add the scroll bars to the window. There is a scrollbar option on the left side menu, but when dragged into the box, the scrollbar looks like it works but in fact doesn't scroll the frame that I put it into.
 
It's generally best to use the actual proper names for things, so we don't have to guess based on approximations. When you say that you're loading windows into frames, do you actually mean that you're loading forms into Panels, or something else? If you use a Panel then you can set its AutoScroll property to True, which it might even be by default, and then it will create scrollbars automatically.
 
There is a scrollbar option on the left side menu, but when dragged into the box, the scrollbar looks like it works but in fact doesn't scroll the frame that I put it into.

If you use the VScrollBar and HScrollBar controls from the Toolbox then it's up to you to do the actual scrolling. They have no knowledge of what you want to happen when the user interacts with them. They simply raise events that you can handle and expose properties that indicate the state of the scroll bar. It's then up to you to make the application behave in whatever way is appropriate for that state.
 
Sorry about that, I'm a total beginner to programming and I am still learning the proper terminology.

I believe when I said "window" I should have said Form. So I have a form with a couple of buttons along the left side, and a panel (Frame) on the right. Clicking on a button loads a new form into the panel.

So, when the new form loads into the panel, depending on which one they have selected, it may not fit inside the dimensions of the panel as I have them set.

What would be involved in adding a scrollbar to the panel so we can see all of the form that has been loaded in?

I've seen the response to my comment regarding the scrollbar from the toolbar.

Is that the simplest way?
 
I would suggest that you're doing it wrong. If you really want to load forms then I'd suggest using the inbuilt MDI functionality. If you just want to load a set of controls into an area then you should be using user controls rather than forms. In either case, scrollbars can be created for you.
 
All container controls have a AutoScroll property. jmcilhinneys previous advice applies too.
 
Turns out the brother of a friend took some C# courses.

We got it to work by wrapping the target frame in a scrollviewer from the toolbar.
 
The ScrollViewer is a WPF control but you have posted this thread in the Windows Forms forum. We were never likely to suggest a WPF solution if we didn't know it was a WPF project. It seems like you actually were using the correct names in the first place, i.e. Window and Frame. Please ensure to post in the most suitable forum and you'll save us all some time and more likely get the help you're after.
 
Back
Top Bottom