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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.