By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

Force a panel to scroll

P: n/a
How do you force a panel to scroll in code.
I have a large picture box inside my panel.
I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner

Thanks
Ray
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Try this

private const int WM_VSCROLL = 0x115;
private const int SB_LINEDOWN = 1;
private const int SB_PAGEUP= 2;
private const int SB_PAGEDOWN= 3;
private const int SB_THUMBPOSITION= 4;
private const int SB_THUMBTRACK= 5;
private const int SB_TOP= 6;
private const int SB_BOTTOM = 7;
private const int SB_ENDSCROLL = 8;

[DllImport("user32.dll")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam,
IntPtr lParam);

// use the constant values based on the functionality
SendMessage(panel1.Handle, WM_VSCROLL, (IntPtr) SB_LINEDOWN , IntPtr.Zero);

--
Shak
(Houston)
"Raymond Dynowski" <de***@tesco.net> wrote in message
news:dV_Dc.103$7I6.72@newsfe1-win...
How do you force a panel to scroll in code.
I have a large picture box inside my panel.
I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner

Thanks
Ray

Nov 16 '05 #2

P: n/a
> I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner I'm not sure what you mean by this... you want to center the picture? Is the
picture larger than the panel in which it's contained?

--
John Wood
EMail: first name, dot, last name, at priorganize.com

"Raymond Dynowski" <de***@tesco.net> wrote in message
news:dV_Dc.103$7I6.72@newsfe1-win... How do you force a panel to scroll in code.
I have a large picture box inside my panel.
I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner

Thanks
Ray

Nov 16 '05 #3

P: n/a
Raymond,
How do you force a panel to scroll in code.
I have a large picture box inside my panel. Have you tried setting the Panel.AutoScrollMinSize to the size of the
picture box, so the scroll bars appear, then set the
Panel.AutoScrollPosition so the PictureBox is "centered".

Be certain to read the help on AutoScrollPosition as the coordinates you
give it to scroll may not be what you initially expect (you need to use
negative offsets sometimes).
I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner Do you want the image to center the panel, or do you really want the panel
to center the screen?

Hope this helps
Jay
"Raymond Dynowski" <de***@tesco.net> wrote in message
news:dV_Dc.103$7I6.72@newsfe1-win... How do you force a panel to scroll in code.
I have a large picture box inside my panel.
I would like the panel to default to the centre of the screen, rather than
the scrollbars showing the top left corner

Thanks
Ray

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.