|
-
Aug 16th, 2019, 10:16 AM
#1
Thread Starter
Lively Member
Panel scrollbar
Dear all,
I have a Form in which I dock a Panel to fill it.
The Panel has the autoscroll property set to True with a minimum scroll set in order to go to the bottom of the page when displaying it.
Now, I'm calling the form from some points of the application, but sometimes it opens the form with the scrollbar at the middle and the following code is resulting me underlined as error:
Code:
Form1.Pnlprincipale.autscrollposition = new Point (Panel1,0)
How can I make it so that every time I open the Form it is shown at the top of the scrollbar?
I tried with the selection of the first field from the top, but the scrollbar position is in any case set at the middle...
Thanks for your help,
A.
-
Aug 16th, 2019, 10:38 AM
#2
Re: Panel scrollbar
The scrollbar depends on the controls that are contained in the panel.
If you don't have any controls in the panel, and the panel doesn't need to scroll (it fits within its container so there is no scroll region), then the scroll thumb should be centered. If you want the scrollbar at the top, then the panel has to have controls beyond the bottom of the container so that and shows that you are at the top of the scroll region and there are controls below the bottom of the container to scroll to.
Last edited by passel; Aug 16th, 2019 at 10:43 AM.
-
Aug 16th, 2019, 10:41 AM
#3
Re: Panel scrollbar
Perhaps place a blank label at the bottom of the panel, below the container will force a scrollable region and the scrollbar will be at the top, but this would be against the normal paradigm of not scrolling below the last used control in the panel.
-
Aug 16th, 2019, 12:15 PM
#4
Thread Starter
Lively Member
Re: Panel scrollbar
Dear passel,
thanks a lot for your kind reply.
I have a lot of controls in the form - that's why I don't understand why it scrolls at the middle of the page.
As written above, I tried even to force the focus on a field when opening the page, but the scrollbar remains at the middle.
Is there a way via code to force the scrollbar to be on top when opening the form?
Thanks,
A.
-
Aug 16th, 2019, 03:32 PM
#5
Re: Panel scrollbar
From your first post, these two statements seemed to conflict to me.
... a minimum scroll set in order to go to the bottom of the page when displaying it.
How can I make it so that every time I open the Form it is shown at the top of the scrollbar?
I'm not sure what the first one means.
How did you force focus, perhaps the focus didn't take?
In the Form's Shown event, if I put something like
Label1.Select
or
Textbox1.Select
Then the panel is scrolled based on the position of the control selected, and if it isn't at or below the size of the container, the scrollbar is at the top.
-
Aug 16th, 2019, 04:09 PM
#6
Addicted Member
Re: Panel scrollbar
The minimum and maximum of a panel vertical scroll bar should automatically adjust from zero to the bottom of the last control.
For example if you have a panel docked in a form that is 450 high and place a button that is sized 20,20 at location 0,600 the span of the scroll bar will be 170.
That is button location-panel height+button height ((600-450)+20=170)
The panel scroll bar can be moved in code to any position in its span which in the above case is 0-170 using the following format
Code:
Panel1.AutoScrollPosition = New Point(0, 130)
So if you wanted the scrollbar at position zero every time the form loaded you would do the following (after all controls have been added to the panel)
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Panel1.AutoScrollPosition = New Point(0,0)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|