[2005] Panel Vertical Scrollbar: scrolling it to zero or top
When a panel's AutoScroll is set True then it will add scrollbars for navigation of the entire size of its content. What I want is to be able to set the vertical scrollbar to go to top or zero so its contents top controls will be viewable.
Anyone who can guide me on how should this be done?
Thank you so much!
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
I think this will do it;
Code:
Me.AutoScrollPosition = New Point(0, 0)
To keep a scroll in position I have used;
Code:
Dim ScrollPosition As Point = Me.AutoScrollPosition
'Do stuff
Me.AutoScrollPosition = New Point( _
Math.Abs(ScrollPosition.X), Math.Abs(ScrollPosition.Y))
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Thanks Bulldog, that should come in handy.
I have searched for a method that I could use in the Panel and ScrollControlIntoView did the trick for me.
1 Attachment(s)
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Arrrggg... Its not working 100% as I've expected.
I am actually trying to tame this bug of a ComponentOne control (DockingTab) wherein upon clicking the tabs then it will scroll the panel to body of the tab where its caption will not be visible anymore.
This is my workaround which partially works:
Code:
private void c1DockingTab1_SelectedIndexChanged(object sender, EventArgs e)
{
panelBuilding.ScrollControlIntoView(c1DockingTab1);
}
But the sad thing is it will not work the first time I select a different tab but will work on succeeding tabs. And again, it will behave as stated earlier when the application lost focus! What a pain... =(
Could anyone suggest some further workarounds I could try? One I idea that I have in mind is to 'lock' the scrolling of the panel if the scrolling was not executed by a user but that would be difficult I guess. I could try hooking some messages like mousescroll or something but perhaps there could be some other way which is more elegant.
EDIT:
Attach is a screenshot of what I am trying to fix.
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Apologies if Im missing the point but cant you set;
Panel1.AutoScrollPosition to a "point" which is equal to where you want the panel displayed?
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Care to elaborate? It is behaving oddly even when the application just loses focus so I am not sure what event should I use.
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
So what happens if when you open the tab (or whatever control it is), in that event you put;
YourControl.AutoScrollPosition = New Point(0, 0)
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
The code I posted in post #4 behaves the same as your suggestion. I have put it in the SelectedIndexChanged of the DockingTab control. I even tried your code if it will make a difference but it did not since it will just be the same as the one I currently have.
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Since it looks like you have a small gap in H and V, then is it a Margin issue? So if in your panel you set YourControl.Margin = New Padding(0) do the scrollbars grow a little?
Re: [2005] Panel Vertical Scrollbar: scrolling it to zero or top
Those are not small gaps but rather two different versions where on image 1 the tab captions are still showing and on image2 the captions are now hidden since the panel has autoscrolled for some reason I am not aware of.
In an attempt to determine what causes the scrollbar to autoscroll like that I have tried using this panel and yet both ScrollVertical and ScrollMouseWheel was not fired when it autoscrolled!
Code:
private void panelBuilding_ScrollVertical(object sender, ScrollEventArgs e)
{
Console.WriteLine(e.Type.ToString() + ':' + e.NewValue.ToString());
}
private void panelBuilding_ScrollMouseWheel(object sender, MouseEventArgs e)
{
Console.WriteLine("Scroll " + e.Delta.ToString() + ':' + this.panelBuilding.AutoScrollHPos.ToString());
}