Using WinForms, C#...
I have a UserControl that contains a few panels.
When I programatically resize the panel, it causes the scroll bar to scroll to the top. I would like to prevent this as it is frustrating for the user to have the control scroll to the top.
I've tried to use "ScrollToControl()" after the resize bu this isnt practical as you still see the form jump and the once focused control is now at the bottom of the control.
Have tried to access the AutoScrollPosition but it returns 0. this.VerticalScroll.Value also returns 0 (where this is the user control before the resize event)
Any suggestions?
Related
OK, this is driving me a bit nuts at this point. Time to ask the crowd:
I have a form that consists of: two vertical "halves" created by a SplitContainer. Inside the bottom "half" / SplitContainer panel... I have:
A set of fields/controls for the user to fill out, contained within a panel.
Below that, a panel containing buttons for "submit", "cancel"...and one that's "show/hide". This "show/hide" is intended to show/hide the panel I just described in point 1 above.
What I want to happen is: when the user clicks to "hide" the panel of controls, not only do those controls vanish, but also:
The panel containing the submit, cancel and show/hide buttons moves up (so that we don't have this big blank space where the now-hidden panel once was).
The form resizes itself vertically so as to make up for the now-hidden panel and the fact that we've moved the bottom controls upwards.
I have no problem getting the panel of controls/fields to show/hide. But I can't seem to figure out how to accomplish the other two tasks. I've tried various combinations of AutoSize, AutoSizeMode, and Dock options.
Any suggestions?
If you put all your controls into a FlowLayoutPanel where the children are arranged vertically, then hiding some controls should cause the "lower" controls to move up the page.
You might still need to write some code to resize the form itself once the optional content has been hidden or before it's shown.
I'm making an instant messaging application in C#. The problem that I'm facing right now is that for the contacts list I've made a custom control extendinguserControl, which contains aFlowLayoutPanel`.
That panel will contain a list of userControls. I want to customize the VscrollBar, but no chance (not possible). Instead I have this genius idea to hide the VscrollBar from the FlowLayoutPanel, and make simple buttons (UP and down events). For this everything worked like a charm, but when I tried to hide the VscrollBar by making the property autoScroll = false , the buttons stopped working.
How can I hide the VscrollBar?
If you want to hide the the vertical bar, there are some possible solutions. ..
You could make an event for resize, controls add, controls remove and set all the child controls' width to flowlayoutpanel.width -20
You could add a panel to the flowlayoutpanel and set it to autosize and make the panels may width to flowlayoutpanel.width-20.
You could check if the width of the flowlayoutpanel is bigger than its real width (means vscrollbar appeared) , and resize the children that it'll/ld hide again
and if you are sure that your controls are smaller than the flowlayoutpanel's width, you simply could create a panel which covers the vertical bar. (use .BringToFront() to put it before the flowlayoutpanel's scrollbar)
I hope that I understood and perhaps have solved the problem
I'm having an issue where my scrollbar for a panel on a usercontrol always appears at the bottom.
If I hover the mouse over the tab and cause the control to slide out and be shown, the scrollbar is at the bottom. If I then move the scrollbar to the top and move the mouse off the control (which causes it to hide again) and then move the mouse back over the tab (which causes the control to slide back out) the scroll bar is back at the bottom!
Setting the VerticalScroll.Value property on my panel to 0 is not having any effect - the control still shows at the bottom. Can someone tell me what events might fire when a control slides back into view on an autohide tab or just tell what I could do to solve this issue! I assume that the Paint event is what fires when the control is shown but I'm not entirely sure.
I did notice that in the VS designer that the scrollbar by default is shown at the bottom. Not sure whether this may have anything to do with the issue?
Any suggestions appreciated!
Try this:
scrollingCtrl.VerticalScroll.Value = 0;
scrollingCtrl.PerformLayout();
A disclaimer first! This might be a very fundamental question, but I have started learning Winforms Application Development on my own (.net 3.5,C#), and I have this resizing question.
I am developing a small Winforms application that has a standard tab control (along with many other controls) placed in the form. (It has 5 TabPages)
The AutoScroll property for the TabPage has been set to “True”. On reading up what I got to understand is that this will enable the scrollbars to show up at run time while resizing. i.e if the height of the form is reduced it will cause the vertical scrollbar to show up within the TabPage.
While the application is running, what I noticed is that if I reduce the height of the form using the little double headed arrow, the scroll bar does not stay on top, i.e if I adjust the height from below, the bottom end of the scrollbar is no longer there. More precisely I am just looking for a way to keep both ends of the scrollbar on top within a TabPage when the form containing the Tab control is resized.
It sounds like the problem is that the tabbed control will show scrollbars and may well autosize, but you haven't told the form what to do.
You might want to look at the 'Dock' property of controls, which causes a control to fill a specific area of the form (or other parent control), no matter what it is resized to.
I am very new to win form.
I want to develop a form which has a height of around 992*1403.
i tried to give the size of the win form as 992*1403, but its taking only 992*876.
i am setting an image of size 992*1403 as the background. i need to put a vertical scroll bar. i put that scroll bar but i dnt know how to write the code when the user scrolls that scroll bar.
Please give me some sample codes or links
For what you are describing, you just need to set the form's Autoscroll property to true. (It is under the "Layout" section). Right-click on the form and select "Properties"
This will add scroll bars if the form doesn't fit into the current window size. No code is required. The scroll bars will only appear when there is a control outside the current view.
Reading your description again, what you might be looking for is a large panel in your form. Add a Panel to your form and make set the location to 0,0 and the size to 992,1403. Then add your controls to the panel. Don't forget to set the form's Autoscroll as mentioned above.