tags:

views:

97

answers:

2

I have a control & I want to attach a vertical scrollbar to my control. Please don't suggest me to use Panel control. Actually. I want to know how to program Windows by C#. Please help me with code in C#. Thanks.

+1  A: 

you can derive your control from system.windows.forms.scrollablecontrol, which will give you the scroll ability.

Benny
I want to know how to attach a system scrollbar. Thanks.
Lu Lu
@Lu Lu, if your control derive from the scrollablecontrol, you will get the scrollbar automatically.
Benny
I want to know the way scrollablecontrol can add a system scrollbar to control.
Lu Lu
+1  A: 

A System Scrollbar in Windows is part of the non-client area of the window. You tell Windows that you want a scrollbars by adding the WS_HSCROLL and WS_VSCROLL styles to the window when it is created.

Then you use Windows functions to set the scrolling range and position of the thumb. You receive WM_HSCROLL and/or WM_VSCROLL messages in your window procedure when the user clicks on your scrollbar or drags the scrollbar thumb. The window class called SCROLLBAR is just a child window with the WS_HSCROLL or WS_VSCROLL style an no client area.

See Scrollbar Functions for information on how to do this in Win32 C++ code.

If you are using .NET forms, you would derive your custom window class from the ScrollableControl class that Benny mentioned.

John Knoeller