Using the SplitContainer control

Source: Internet
Author: User

8.6 Using the SplitContainer control

In Windows Explorer, when you move the mouse pointer between the TreeView control and the ListView control, you can drag the mouse left and right to resize the TreeView control and the ListView control in the main window to accommodate the different display contents. We can use the SplitContainer control to implement this functionality.

You can consider a SplitContainer control as a composite, which is a two panel separated by a movable splitter bar. When the mouse pointer hovers over the splitter bar, the pointer changes the shape accordingly to show that the splitter bar is movable. Using the SplitContainer control, you can create a composite user interface (typically, the selection in one panel determines which objects are displayed in another panel). This arrangement is useful for displaying and browsing information. With two panels, you can aggregate information from different regions, and users can easily resize the panel using a splitter bar (also known as a splitter).

First set the Dock property of the Rsstreeview and Rsslistview controls to none, and then properly size the two controls, leaving a certain blank area of the main form. Then drag and drop a SplitContainer control from the Toolbox into an empty area of the main form, where the Panel1 and Panel2 two containers appear on the left and right sides of the control, and the controls placed in the two containers can be sized proportionally. The size of the two containers is adjusted by the user using the splitter bar. Drag and drop a label control into Panel1, set the Text property to the list of RSS documents, set the Dock property to top, then drag and drop the Rsstreeview control into Panel1, and drag and drop the Rsslistview control into Panel2. The dock properties of both controls are then set to fill, filled with the panel,8.16 shown in their respective fields.

(Click to view larger image) Figure 8.16 SplitContainer Control

Set the Dock property of the SplitContainer control to fill, fill the entire main form, and set the Fixedpanel property to Panel1 so that the size of the PANEL1 panel does not change by default when resizing the main form ; Set the Panel1minsize property to 50, which sets the minimum width of the Panel1 container; Similarly, set the Panel2minsize property to 100. Properties panel1collapsed and panel2collapsed respectively set Panel1 and Panel2 Two containers are collapsed, so-called folding is whether to hide a certain panel. The Splitterdistance property sets the distance between the splitter bar and the left side of the SplitContainer control. The Splitterincrement property sets the distance to move each time the user drags the splitter bar. The Splitterwidth property sets the width of the splitter bar. The Orientation property determines the direction of the splitter, not the direction of the control itself. Therefore, when the property is set to vertical, the splitter is placed vertically, resulting in the left and right panels.

Now we run the program again, you can try dragging the splitter with the mouse to change the size ratio of the Rsstreeview and Rsslistview controls, as shown in 8.17.

(Click to view larger image) Figure 8.17 running effect

Using the SplitContainer control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.