HScroller.Scroll += new (hScroller_Scroll) The following code snippet adds an event handler for the Scroll event. For example, we can implement scrolling in a PictureBox control by displaying image in a PictureBox again on the scroll event bar. On the scroll event hander, we usually read the current value of an HScrollBar and based on this value, we apply on other controls. Horizontal scroll bar control is attached to a control by its scroll event. The following code snippet sets the Minimum, Maximum, and Value properties of an HScrollBar control. The Minimum and Maximum properties are used to set minimum and maximum limit of an HScrollBar. Value property of an HScrollBar represents the current value of an HScrollBar control. The following code snippet sets and gets the name and text of an HScrollBar control. It is used to access the control in the code. Name property represents a unique name of an HScrollBar control. The following code snippet sets Dock, Width, and Height properties of an HScrollBar control. The Dock property is used to dock a control. We can also use Width and Height property instead of Size property. The Size property specifies the size of the control. The Location property takes a Point that specifies the starting position of the HScrollBar on a Form. The Properties window looks like Figure 2. You can open Properties window by pressing F4 or right click on a control and select Properties menu item. The easiest way to set properties is from the Properties Window. The following code snippet adds an HScrollBar control to the current Form.Īfter you place an HScrollBar control on a Form, the next step is to set properties. Once an HScrollBar control is ready with its properties, next step is to add the HScrollBar control to the Form. The following code snippet sets the height and width properties of an HScrollBar. In the next step, you may set properties of an HScrollBar control. The following code snippet creates an HScrollBar control object. Once an HScrollBar is on the Form, you can move it around and resize it using mouse and set its properties and events.Ĭreating an HScrollBar control at run-time is merely a work of creating an instance of HScrollBar class, set its properties and add HScrollBar class to the Form controls.įirst step to create a dynamic HScrollBar is to create an instance of HScrollBar class. After you drag and drop an HScrollBar on a Form, the HScrollBar looks like Figure 1. To create an HScrollBar control at design-time, you simply drag and drop an HScrollBar control from Toolbox to a Form in Visual Studio. We can create an HScrollBar control using a Forms designer at design-time or using the HScrollBar class in code at run-time (also known as dynamically). After that, I will discuss various properties and methods available for the HScrollBar control. In this article, I will discuss how to create an HScrollBar control and apply horizontal scrolling on Windows Forms controls that do not have built-in scrolling feature. You do not need this control for the controls that already have built-in scrolling. An HScrollBar control is a supporting control that is used to add horizontal scrolling capability to a control that does not have built-in scrolling such as a container control.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |