Panel & external VScrollBar

  • Thread starter Thread starter Sascha Schmidt
  • Start date Start date
S

Sascha Schmidt

Hello !

I'm trying to combine an external (not part of the panel)
vertical scrollbar (VScrollBar) with a panel in order to
scroll the content of the panel vertically using the external
VScrollbar. I can't set the "AutoScroll"-property to true and
then use the generated scrollbars inside the panel,
because i have to use this external scrollbar which is a
modified/customized scrollbar, and doesn't look like a
standard scrollbar.

I've experiemented a litte bit, but until now i'm quite unsure.
What is a good way to to achieve this?
Source samples are highly appreciated.

Thanks in advance and have a nice weekend !
Sascha
 
Sascha,

I would have a property on the Panel (or take these values in the
constructor, assuming that you are deriving your class from Panel) which
takes the scrollbars that are to be used to manipulate the view. Then, you
can attach to the events indicating that the value of the scrollbar changes,
and adjust your view appropriately.

Either that, or expose a method where you can set what the panel is
viewing and have the event handler for the container control link the two
together when the scrollbars change.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello !

I'm trying to combine an external (not part of the panel)
vertical scrollbar (VScrollBar) with a panel in order to
scroll the content of the panel vertically using the external
VScrollbar. I can't set the "AutoScroll"-property to true and
then use the generated scrollbars inside the panel,
because i have to use this external scrollbar which is a
modified/customized scrollbar, and doesn't look like a
standard scrollbar.

I've experiemented a litte bit, but until now i'm quite unsure.
What is a good way to to achieve this?
Source samples are highly appreciated.

Thanks in advance and have a nice weekend !
Sascha
 
Hello again!

To describe my problem more precisely:
It's more a technical than an architectical problem.

Until now i discovered two ways to manipulate the "scroll-position"
of the frame:
Using window messages to move one line up and down, for example

SendMessage(pnlScroll.ThePanel.Handle, WM_VSCROLL, SB_TOP, new
IntPtr(0));

or modify the coordinates of the property "AutoScrollPosition"
in the "Scroll"-Event of the external scrollbar like :

private void sgvScrollBar1_Scroll(object sender,
System.Windows.Forms.ScrollEventArgs e)
{
int modifFactor = 3;
pnlScroll.ThePanel.AutoScrollPosition = new Point(0, e.NewValue *
modifFactor);
}

Both solutions provide scrolling, but until the "AutoScroll" - property
is set to true (i can't do this, you remember ?) both can't scroll
completly down to the bottom (they stop about 2/3 of the way).

I changed the "modifFactor", but that doesn't change.

So my remaining questions are:
1) How do i get a scroll solution that is fully functional
(among other things: Scroll fully to bottom) ?
2) How do i calculate the "min" and "max" property for
the external Scrollbar, so that it fits to the size of
the panel ?
3) Is the event "Scroll"-event of the scrollbar the right
one for this purpose? Do i need other properties / events
of the scrollbar?

Again, thanks in advance
Sascha
 
Back
Top