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.
you can derive your control from system.windows.forms.scrollablecontrol, which will give you the scroll ability.
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.