Sie sind auf Seite 1von 64

ComponentOne

SplitContainer for WinForms

Copyright 1987-2010 ComponentOne LLC. All rights reserved.


Corporate Headquarters ComponentOne LLC 201 South Highland Avenue 3rd Floor Pittsburgh, PA 15206 USA Internet: Web site: info@ComponentOne.com http://www.componentone.com

Sales E-mail: sales@componentone.com Telephone: 1.800.858.2739 or 1.412.681.4343 (Pittsburgh, PA USA Office)

Trademarks The ComponentOne product name is a trademark and ComponentOne is a registered trademark of ComponentOne LLC. All other trademarks used herein are the properties of their respective owners. Warranty ComponentOne warrants that the original CD (or diskettes) are free from defects in material and workmanship, assuming normal use, for a period of 90 days from the date of purchase. If a defect occurs during this time, you may return the defective CD (or disk) to ComponentOne, along with a dated proof of purchase, and ComponentOne will replace it at no charge. After 90 days, you can obtain a replacement for a defective CD (or disk) by sending it and a check for $25 (to cover postage and handling) to ComponentOne. Except for the express warranty of the original CD (or disks) set forth here, ComponentOne makes no other warranties, express or implied. Every attempt has been made to ensure that the information contained in this manual is correct as of the time it was written. We are not responsible for any errors or omissions. ComponentOnes liability is limited to the amount you paid for the product. ComponentOne is not liable for any special, consequential, or other damages for any reason. Copying and Distribution While you are welcome to make backup copies of the software for your own use and protection, you are not permitted to make copies for the use of anyone else. We put a lot of time and effort into creating this product, and we appreciate your support in seeing that it is used by licensed users only. This manual was produced using ComponentOne Doc-To-Help.

Table of Contents
ComponentOne SplitContainer for WinForms Overview ............................................................... 5 Installing SplitContainer for WinForms .................................................................................................... 5 SplitContainer for WinForms Setup Files ................................................................................................. 5 System Requirements ............................................................................................................................... 6 Installing Demonstration Versions ............................................................................................................ 6 Uninstalling SplitContainer for WinForms ............................................................................................... 6 End-User License Agreement ................................................................................................................... 7 Licensing FAQs ....................................................................................................................................... 7 What is Licensing? ................................................................................................................................... 7 How does Licensing Work? ...................................................................................................................... 7 Common Scenarios .................................................................................................................................. 8 Common Scenarios in Mobile Applications ............................................................................................ 10 Troubleshooting ..................................................................................................................................... 11 Technical Support .................................................................................................................................. 12 Redistributable Files ............................................................................................................................... 13 About This Documentation .................................................................................................................... 13 Namespaces ........................................................................................................................................... 14 Creating a .NET Project ......................................................................................................................... 15 Adding the C1SplitContainer Component to a Project ............................................................................ 16 Key Features.......................................................................................................................19 SplitContainer for WinForms Quick Start .................................................................................20 Step 1 of 4: Adding C1SplitContainer to the Page .................................................................................. 20 Step 2 of 4: Adding C1SplitterPanels to the C1SplitContainer ................................................................. 21 Step 3 of 4: Creating Collapsible Panels .................................................................................................. 22 Step 4 of 4: Sizing the C1SplitContainer Control.................................................................................... 24 Design-Time Support ............................................................................................................24 C1SplitContainer Smart Tags ................................................................................................................. 25 C1SplitContainer Tasks Menu ................................................................................................................ 25 C1Splitter Panel Tasks Menu.................................................................................................................. 26 SplitContainer Elements........................................................................................................27 Splitter Panels ........................................................................................................................................ 27 Panel Header.......................................................................................................................................... 28 Splitter Bar ............................................................................................................................................. 29 Expander Button .................................................................................................................................... 29 SplitContainer Appearance ....................................................................................................30 SplitContainer Visual Styles ................................................................................................................... 30 SplitContainer Appearance Properties .................................................................................................... 32 SplitContainer Layout ..........................................................................................................33 SplitContainer Layout Options ............................................................................................................... 34 Horizontal Split ...................................................................................................................................... 35 Vertical Split .......................................................................................................................................... 35 Compound Split ..................................................................................................................................... 36 Full-Size Split ......................................................................................................................................... 36 SplitterPanel Behavior ..........................................................................................................37 Collapsible and Expandable Panels ........................................................................................................ 37 SplitterPanel Scrolling ............................................................................................................................ 38 SplitterPanel and Splitter Bar Sizing ....................................................................................................... 38

iii

OwnerDraw Panel Header and Splitter ................................................................................................... 39 SplitContainer for WinForms Samples .....................................................................................39 SplitContainer for WinForms Task-Based Help ..........................................................................41 Adding Content to the Splitter Panels ..................................................................................................... 41 Adding Arbitrary Controls to the C1SplitterPanel ................................................................................... 41 Adding Text to a Splitter Panel ............................................................................................................... 43 Adding Multiple Panels to the C1SplitContainer .................................................................................... 45 Changing the C1SplitContainers Appearance ........................................................................................ 47 Changing the Background Color of Panels .............................................................................................. 47 Changing the Border Color ..................................................................................................................... 49 Changing the Visual Style ....................................................................................................................... 51 Changing the Splitter Width ................................................................................................................... 52 Creating Different Split Types ................................................................................................................ 54 Creating a Horizontal Split ..................................................................................................................... 54 Creating a Vertical Split .......................................................................................................................... 56 Creating a Nested Split ........................................................................................................................... 58 Creating a Full-Size Split ........................................................................................................................ 58 Setting C1SplitContainer Behaviors ........................................................................................................ 60 Adding a ToolTip to the Collapsed Splitter Panel ................................................................................... 60 Setting a Minimum Size for a Splitter Panel ............................................................................................ 61 Setting a Collapsible Splitter Panel ......................................................................................................... 62

iv

ComponentOne SplitContainer for WinForms Overview


Create highly sophisticated resizable panels in your applications without using any resizing code with ComponentOne SplitContainer for WinForms (C1SplitContainer). C1SplitContainers WYSIWYG designer, support for multiple panels inside a container, and wide range of appearance properties gives you a customizable and flexible split container control that is very easy to use. C1SplitContainer is a container control for resizable docked panels. The C1SplitContainer control allows you to dock multiple panels to either side of the container control. ComponentOne SplitContainer for WinForms includes many features such as flexible layout (nested panels, resizable panels, and collapsing handles), and user interface features (including Office 2007 and Office 2010 Visual Styles), that you can use to create complex user interfaces.
Getting Started

- SplitContainer for WinForms Quick Start (page 20) - SplitContainer Layout (page 33) - SplitContainer for WinForms Task-Based Help (page 41)

Installing SplitContainer for WinForms


This section describes the set up files and system requirements for SplitContainer for WinForms. It also explains how to install demonstration versions of ComponentOne products and uninstall SplitContainer for WinForms.

SplitContainer for WinForms Setup Files


The ComponentOne Studio for WinForms installation program will create the following directory: C:\Program Files\ComponentOne\Studio for Winforms. This directory contains the following subdirectories: Contains copies of all ComponentOne binaries (DLLs, EXEs) Contains files (at least a readme.txt) related to the SplitContainer for WinForms product.

bin C1SplitContainer

The ComponentOne Studio for WinForms Help Setup program installs integrated Microsoft Help Viewer help to the C:\Program Files\ComponentOne\Studio for WinForms\HelpViewer folder. Samples Samples for the product are installed in the ComponentOne Samples folder by default. The path of the ComponentOne Samples directory is slightly different on Windows XP and Windows Vista machines: Windows XP path: C:\Documents and Settings\<username>\My Documents\ComponentOne Samples

Windows Vista path: C:\Users\<username>\Documents\ComponentOne Samples The ComponentOne Samples folder contains the following subdirectories: Contains support and data files that are used by many of the demo programs. Contains samples and tutorials for SplitContainer for WinForms.

Common C1SplitContainer

Samples can be accessed from the ComponentOne Sample Explorer. On your desktop, click the Start button and then click ComponentOne | Studio for WinForms| Samples |SplitContainer Samples.

System Requirements
System requirements include the following: Windows 7 Windows 2000 Windows Server 2003 Windows Server 2008 Windows XP SP2 Windows Vista Environments: .NET Framework 2.0 or later C# .NET Visual Basic .NET Disc Drive: CD or DVD-ROM drive if installing from CD

Operating Systems:

Installing Demonstration Versions


If you wish to try ComponentOne SplitContainer for WinForms and do not have a serial number, follow the steps through the installation wizard and use the default serial number. The only difference between unregistered (demonstration) and registered (purchased) versions of our products is that registered versions will stamp every application you compile so a ComponentOne banner will not appear when your users run the applications.

Uninstalling SplitContainer for WinForms


To uninstall ComponentOne SplitContainer for WinForms: 1. 2. 3. Open the Control Panel and select the Add or Remove Programs (Programs and Features in Windows 7/Vista). Select ComponentOne Studio for WinForms and click the Remove button. Click Yes to remove the program.

End-User License Agreement


All of the ComponentOne licensing information, including the ComponentOne end-user license agreements, the ComponentOne licensing model, and frequently asked licensing questions, is available online at http://www.componentone.com/SuperPages/Licensing/.

Licensing FAQs
This section describes the main technical aspects of licensing. It may help the user to understand and resolve licensing problems he may experience when using ComponentOne .NET and ASP.NET products.

What is Licensing?
Licensing is a mechanism used to protect intellectual property by ensuring that users are authorized to use software products. Licensing is not only used to prevent illegal distribution of software products. Many software vendors, including ComponentOne, use licensing to allow potential users to test products before they decide to purchase them. Without licensing, this type of distribution would not be practical for the vendor or convenient for the user. Vendors would either have to distribute evaluation software with limited functionality, or shift the burden of managing software licenses to customers, who could easily forget that the software being used is an evaluation version and has not been purchased.

How does Licensing Work?


ComponentOne uses a licensing model based on the standard set by Microsoft, which works with all types of components.
Note: The Compact Framework components use a slightly different mechanism for run-time licensing than the other ComponentOne components due to platform differences.

When a user decides to purchase a product, he receives an installation program and a Serial Number. During the installation process, the user is prompted for the serial number that is saved on the system. (Users can also enter the serial number by clicking the License button on the About Box of any ComponentOne product, if available, or by rerunning the installation and entering the serial number in the licensing dialog.) When a licensed component is added to a form or web page, Visual Studio obtains version and licensing information from the newly created component. When queried by Visual Studio, the component looks for licensing information stored in the system and generates a run-time license and version information, which Visual Studio saves in the following two files: An assembly resource file which contains the actual run-time license A "licenses.licx" file that contains the licensed component strong name and version information These files are automatically added to the project by Microsoft Visual Studio. In WinForms and ASP.NET 1.x applications, the run-time license is stored as an embedded resource in the assembly hosting the component or control by Visual Studio. In ASP.NET 2.x applications, the run-time license may also be stored as an embedded resource in the App_Licenses.dll assembly, which is used to store all run-time licenses for all components directly hosted by WebForms in the application. Thus, the App_licenses.dll must always be deployed with the application. The licenses.licx file is a simple text file that contains strong names and version information for each of the licensed components used in the application. Whenever Visual Studio is called upon to rebuild the application resources, this file is read and used as a list of components to query for run-time licenses to be embedded in the appropriate assembly resource. Note that editing or adding an appropriate line to this file can force Visual Studio to add run-time licenses of other controls as well.

Note that the licenses.licx file is usually not shown in the Solution Explorer; it appears if you press the Show All Files button in the Solution Explorer's toolbox, or from Visual Studio's main menu, select Show All Files on the Project menu. Later, when the component is created at run time, it obtains the run-time license from the appropriate assembly resource that was created at design time and can decide whether to simply accept the run-time license, to throw an exception and fail altogether, or to display some information reminding the user that the software has not been licensed. All ComponentOne products are designed to display licensing information if the product is not licensed. None will throw licensing exceptions and prevent applications from running.

Common Scenarios
The following topics describe some of the licensing scenarios you may encounter.

Creating components at design time


This is the most common scenario and also the simplest: the user adds one or more controls to the form, the licensing information is stored in the licenses.licx file, and the component works. Note that the mechanism is exactly the same for Windows Forms and Web Forms (ASP.NET) projects.

Creating components at run time


This is also a fairly common scenario. You do not need an instance of the component on the form, but would like to create one or more instances at run time. In this case, the project will not contain a licenses.licx file (or the file will not contain an appropriate run-time license for the component) and therefore licensing will fail. To fix this problem, add an instance of the component to a form in the project. This will create the licenses.licx file and things will then work as expected. (The component can be removed from the form after the licenses.licx file has been created). Adding an instance of the component to a form, then removing that component, is just a simple way of adding a line with the component strong name to the licenses.licx file. If desired, you can do this manually using notepad or Visual Studio itself by opening the file and adding the text. When Visual Studio recreates the application resources, the component will be queried and its run-time license added to the appropriate assembly resource.

Inheriting from licensed components


If a component that inherits from a licensed component is created, the licensing information to be stored in the form is still needed. This can be done in two ways: Add a LicenseProvider attribute to the component. This will mark the derived component class as licensed. When the component is added to a form, Visual Studio will create and manage the licenses.licx file, and the base class will handle the licensing process as usual. No additional work is needed. For example: [LicenseProvider(typeof(LicenseProvider))] class MyGrid: C1.Win.C1FlexGrid.C1FlexGrid { // ... } Add an instance of the base component to the form. This will embed the licensing information into the licenses.licx file as in the previous scenario, and the base component will find it and use it. As before, the extra instance can be deleted after the licenses.licx file has been created.

Please note, that C1 licensing will not accept a run time license for a derived control if the run time license is embedded in the same assembly as the derived class definition, and the assembly is a DLL. This restriction is necessary to prevent a derived control class assembly from being used in other applications without a design time license. If you create such an assembly, you will need to take one of the actions previously described create a component at run time.

Using licensed components in console applications


When building console applications, there are no forms to add components to, and therefore Visual Studio won't create a licenses.licx file. In these cases, create a temporary Windows Forms application and add all the desired licensed components to a form. Then close the Windows Forms application and copy the licenses.licx file into the console application project. Make sure the licenses.licx file is configured as an embedded resource. To do this, right-click the licenses.licx file in the Solution Explorer window and select Properties. In the Properties window, set the Build Action property to Embedded Resource.

Using licensed components in Visual C++ applications


There is an issue in VC++ 2003 where the licenses.licx is ignored during the build process; therefore, the licensing information is not included in VC++ applications. To fix this problem, extra steps must be taken to compile the licensing resources and link them to the project. Note the following: 1. 2. 3. 4. 5. Build the C++ project as usual. This should create an exe file and also a licenses.licx file with licensing information in it. Copy the licenses.licx file from the app directory to the target folder (Debug or Release). Copy the C1Lc.exe utility and the licensed dlls to the target folder. (Don't use the standard lc.exe, it has bugs.) Use C1Lc.exe to compile the licenses.licx file. The command line should look like this: c1lc /target:MyApp.exe /complist:licenses.licx /i:C1.Win.C1FlexGrid.dll Link the licenses into the project. To do this, go back to Visual Studio, right-click the project, select properties, and go to the Linker/Command Line option. Enter the following: /ASSEMBLYRESOURCE:Debug\MyApp.exe.licenses Rebuild the executable to include the licensing information in the application.

6.

Using licensed components with automated testing products


Automated testing products that load assemblies dynamically may cause them to display license dialogs. This is the expected behavior since the test application typically does not contain the necessary licensing information, and there is no easy way to add it. This can be avoided by adding the string "C1CheckForDesignLicenseAtRuntime" to the AssemblyConfiguration attribute of the assembly that contains or derives from ComponentOne controls. This attribute value directs the ComponentOne controls to use design time licenses at run time. For example: #if AUTOMATED_TESTING [AssemblyConfiguration("C1CheckForDesignLicenseAtRuntime")] #endif public class MyDerivedControl : C1LicensedControl { // ... }

Note that the AssemblyConfiguration string may contain additional text before or after the given string, so the AssemblyConfiguration attribute can be used for other purposes as well. For example: [AssemblyConfiguration("C1CheckForDesignLicenseAtRuntime,BetaVersion")] THIS METHOD SHOULD ONLY BE USED UNDER THE SCENARIO DESCRIBED. It requires a design time license to be installed on the testing machine. Distributing or installing the license on other computers is a violation of the EULA.

Common Scenarios in Mobile Applications


The following topics describe some of the licensing scenarios you may encounter when working with Mobile components.

Updating or renewing a license


If you renew your subscription, the new license must be installed. If the Mobile controls are licensed through a Studio subscription, then open the About Box of either an ASP.NET control or a .NET Windows forms control and update the license by clicking the License button and entering your serial number. If the Mobile controls are licensed through a Studio for Mobile Devices subscription, then open the About Box of the 1.x version of a Mobile control or run the setup again to enter your serial number. Presently, the 2.x versions of the Mobile controls do not have the option to license or register from the About Box; therefore, it is necessary to license through another component or the setup. Licensing 2.x Mobile Controls through the Setup To enter the serial number (license) through the Studio for Mobile Devices 2.0 setup, follow these steps: 1. 2. Run the ComponentOne Studio for Mobile Devices 2.0 setup. Follow the instructions in the setup, and enter the serial number when prompted.

There are cases where the setup may not prompt you. If you have a valid license installed already, or if you are installing a version of the controls that has already been installed (Maintenance Mode), you will not be prompted to enter your serial number. If you need to enter your serial number for an install, and the install is running in Maintenance Mode, you will need to uninstall first. Once you uninstall, run the install again. If you are still not prompted for a serial number by the time you get to the install screen, you must have a valid license in the registry on your machine. If you still need to install a new serial number, remove the old license and then run the setup again. There is a utility available that will remove the old license for you, which can be found below. License Remover The license remover will search for the following licenses on your system: Studio Enterprise, Studio for Mobile Devices, and individual Studio Mobile product licenses. Any licenses that are found will be populated into a list so that you can select the ones that you would like to remove. To remove a Studio for Mobile Devices license with the license remover, follow these steps: 1. 2. Unzip and run the C1LicBomb.exe. You will see an app with a list of the installed licenses on your machine. If you see both Studio Enterprise and Studio for Mobile devices listed, select both for removal, otherwise select the one that you see. If the new serial number that you wish to enter for Studio for Mobile Devices is not a Studio Enterprise serial number, you will need to enter your Studio Enterprise serial number again, but this can be done through any of the About Boxes for C1 controls with the exception of the Mobile Studio About Boxes. Select any other licenses you wish to remove, then click the Remove Selected Licenses button. You will be asked if you are sure that you want to delete each key; click OK when you get the dialog box.

3. 4.

10

5. 6.

There will also be a dialog box to let you know that a particular key was removed successfully; click OK for that one also. Now you can close the program and run your Studio for Mobile Devices setup again to enter your new serial number.

Follow through with the setup, enter your serial number when prompted, and ComponentOne Studio for Mobile Devices will be licensed on your machine.

Updating a project after renewing a license


Once you have installed a new license, each project must be updated in order to use the new control; rebuilding the control is not sufficient. It is necessary for the control to regenerate the license embedded in its SupportInfo property. To do this, it is necessary to force Visual Studio to update the control properties stored in the form. The easiest way to do this is to simply modify a property. The simplest choice is to toggle a Boolean property such as the Visible property, and then toggle it back to its original value. This results in no changes or side effects in the control configuration, but it forces the IDE to update SupportInfo and embed the new run-time license.

Instantiating a Mobile control at run time


The Mobile controls behave the same way as other ComponentOne controls when they are created at run time and not placed on the form at design time. Because the IDE does not have an opportunity to obtain a run-time license on its own in this case, it is necessary to force the IDE to include a run-time license. To accomplish this, include at least one instance of the control on a form in the assembly that is instantiated BEFORE the dynamically created instance is created. Once a control of the same type is licensed, all others on the form are accepted as licensed.

Troubleshooting
We try very hard to make the licensing mechanism as unobtrusive as possible, but problems may occur for a number of reasons. Below is a description of the most common problems and their solutions.

I have a licensed version of a ComponentOne product but I still get the splash screen when I run my project.
If this happens, there may be a problem with the licenses.licx file in the project. It either doesn't exist, contains wrong information, or is not configured correctly. First, try a full rebuild (Rebuild All from the Visual Studio Build menu). This will usually rebuild the correct licensing resources. If that fails follow these steps: 1. 2. 3. 4. Open the project and go to the Solution Explorer window. Click the Show All Files button on the top of the window. Find the licenses.licx file and open it. If prompted, continue to open the file. Change the version number of each component to the appropriate value. If the component does not appear in the file, obtain the appropriate data from another licenses.licx file or follow the alternate procedure following. Save the file, then close the licenses.licx tab. Rebuild the project using the Rebuild All option (not just Rebuild). Open the project and go to the Solution Explorer window. Click the Show All Files button on the top of the window.

5. 6. 1. 2.

Alternatively, follow these steps:

11

3. 4. 5. 6. 7. 1. 2. 3. 4.

Find the licenses.licx file and delete it. Close the project and reopen it. Open the main form and add an instance of each licensed control. Check the Solution Explorer window, there should be a licenses.licx file there. Rebuild the project using the Rebuild All option (not just Rebuild). Open the project and go to the Solution Explorer window. Find the licenses.licx file and right-click it. Select the Rebuild Licenses option (this will rebuild the App_Licenses.licx file). Rebuild the project using the Rebuild All option (not just Rebuild).

For ASP.NET 2.x applications, follow these steps:

I have a licensed version of a ComponentOne product on my web server but the components still behave as unlicensed.
There is no need to install any licenses on machines used as servers and not used for development. The components must be licensed on the development machine, therefore the licensing information will be saved into the executable (.exe or .dll) when the project is built. After that, the application can be deployed on any machine, including web servers. For ASP.NET 2.x applications, be sure that the App_Licenses.dll assembly created during development of the application is deployed to the bin application bin directory on the web server. If your ASP.NET application uses WinForms user controls with constituent licensed controls, the runtime license is embedded in the WinForms user control assembly. In this case, you must be sure to rebuild and update the user control whenever the licensed embedded controls are updated.

I downloaded a new build of a component that I have purchased, and now I'm getting the splash screen when I build my projects.
Make sure that the serial number is still valid. If you licensed the component over a year ago, your subscription may have expired. In this case, you have two options: Option 1 - Renew your subscription to get a new serial number. If you choose this option, you will receive a new serial number that you can use to license the new components (from the installation utility or directly from the About Box). The new subscription will entitle you to a full year of upgrades and to download the latest maintenance builds directly from http://prerelease.componentone.com/. Option 2 Continue to use the components you have. Subscriptions expire, products do not. You can continue to use the components you received or downloaded while your subscription was valid.

Technical Support
ComponentOne offers various support options. For a complete list and a description of each, visit the ComponentOne Web site at http://www.componentone.com/SuperProducts/SupportServices/. Some methods for obtaining technical support include: Online Resources

12

ComponentOne provides customers with a comprehensive set of technical resources in the form of FAQs, samples and videos, Version Release History, searchable Knowledge base, searchable Online Help and more. We recommend this as the first place to look for answers to your technical questions. Online Support via our Incident Submission Form This online support service provides you with direct access to our Technical Support staff via an online incident submission form. When you submit an incident, you'll immediately receive a response via e-mail confirming that you've successfully created an incident. This e-mail will provide you with an Issue Reference ID and will provide you with a set of possible answers to your question from our Knowledgebase. You will receive a response from one of the ComponentOne staff members via e-mail in 2 business days or less. Product Forums ComponentOnes product forums are available for users to share information, tips, and techniques regarding ComponentOne products. ComponentOne developers will be available on the forums to share insider tips and technique and answer users questions. Please note that a ComponentOne User Account is required to participate in the ComponentOne Product Forums. Installation Issues Registered users can obtain help with problems installing ComponentOne products. Contact technical support by using the online incident submission form or by phone (412.681.4738). Please note that this does not include issues related to distributing a product to end-users in an application. Documentation Microsoft integrated ComponentOne documentation can be installed with each of our products, and documentation is also available online. If you have suggestions on how we can improve our documentation, please email the Documentation team. Please note that e-mail sent to the Documentation team is for documentation feedback only. Technical Support and Sales issues should be sent directly to their respective departments.
Note: You must create a ComponentOne Account and register your product with a valid serial number to obtain support using some of the above methods.

Redistributable Files
ComponentOne SplitContainer for WinForms is developed and published by ComponentOne LLC. You may use it to develop applications in conjunction with Microsoft Visual Studio or any other programming environment that enables the user to use and integrate the control(s). You may also distribute, free of royalties, the following Redistributable Files with any such application you develop to the extent that they are used separately on a single CPU on the client/workstation side of the network: C1.Win.C1SplitContainer.4.dll C1.Win.C1SplitContainer.4.Design.dll

Site licenses are available for groups of multiple developers. Please contact Sales@ComponentOne.com for details.

About This Documentation


Acknowledgements Microsoft, Windows, Windows Vista, and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. ComponentOne If you have any suggestions or ideas for new features or controls, please call us or write:

13

Corporate Headquarters ComponentOne LLC 201 South Highland Avenue 3rd Floor Pittsburgh, PA 15206 USA 412.681.4343 412.681.4384 (Fax) http://www.componentone.com ComponentOne Doc-To-Help This documentation was produced using ComponentOne Doc-To-Help Enterprise.

Namespaces
Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries. The general namespace for ComponentOne Windows products is C1.Win. The general namespace for ComponentOne Web-based products is C1.Web. The namespace for the C1SplitContainer control is C1.Win.C1SplitContainer. The following code fragment shows how to declare a C1SplitContainer control using the fully qualified name for this class: Visual Basic Dim splitcontainer As C1.Win.C1SplitContainer.C1SplitContainer C# C1.Win.C1SplitContainer.C1SplitContainer splitcontainer;

Namespaces address a problem sometimes known as namespace pollution, in which the developer of a class library is hampered by the use of similar names in another library. These conflicts with existing components are sometimes called name collisions. For example, if a new class named C1SplitterPanel is created, it can be used inside the project without qualification. However, the C1SplitContainer assembly also implements a class called C1SplitterPanel. So, if the C1SplitterPanel class will be used in the same project, a fully qualified reference must be used to make the reference unique. If the reference is not unique, Visual Studio .NET produces an error stating that the name is ambiguous. Fully qualified names are object references that are prefixed with the name of the namespace where the object is defined. Objects defined in other projects can be used if a reference to the class is created (by choosing Add Reference from the Project menu) and then using the fully qualified name for the object in the code. Fully qualified names prevent naming conflicts because the compiler can always determine which object is being used. However, the names themselves can get long and cumbersome. To get around this, you can use the Imports statement (using in C#) to define an alias an abbreviated name you can use in place of a fully qualified name. For example, the following code snippet creates aliases for two fully qualified names, and uses these aliases to define two objects: Visual Basic Imports C1SplitterPanel = C1.Win.C1SplitContainer.C1SplitterPanel Imports MySplitterPanel = C1.Win.C1SplitContainer.C1SplitterPanel Dim SP1 As C1SplitterPanel Dim SP2 As C1SplitterPanel

14

C# using C1SplitterPanel = C1.Win.C1SplitContainer.C1SplitterPanel; using MySplitterPanel = C1.Win.C1SplitContainer.C1SplitterPnalel; C1SplitterPanel SP1; MySplitterPanel SP2;

If the Imports statement is used without an alias, use all the names in that namespace without qualification provided they are unique to the project. As a warning, unless specified explicitly in the code, it is taken for granted that the following statement has been specified: Visual Basic Imports C1.Win.C1SplitContainer C# using C1.Win.C1SplitContainer;

This applies only to small code samples. Tutorials and other longer samples will specify complete qualifiers.

Creating a .NET Project


To create a new .NET project, complete the following steps: 1. 2. 3. From the File menu in Microsoft Visual Studio .NET, select New Project. The New Project dialog box opens. Under Project Types, choose either Visual Basic or Visual C#. Note that one of these options may be located under Other Languages. Select Windows Forms Application from the list of Templates in the right pane.

4.

Enter or browse for a location for your application in the Location field and click OK.

A new Microsoft Visual Studio .NET project is created in the specified location. In addition, a new Form1 is displayed in the Designer view. 5. Double-click the C1SplitContainer component from the Toolbox to add it to Form1. For information on adding a component to the toolbox, see Adding the C1SplitContainer Component to a Project.

15

Adding the C1SplitContainer Component to a Project


When you install ComponentOne Studio for WinForms, the Create a ComponentOne Visual Studio Toolbox Tab checkbox is checked, by default, in the installation wizard. When you open Visual Studio, you will notice a ComponentOne Studio for WinForms tab containing the ComponentOne controls has automatically been added to the Toolbox. If you decide to uncheck the Create a ComponentOne Visual Studio Toolbox Tab checkbox during installation, you can manually add ComponentOne controls to the Toolbox at a later time. ComponentOne SplitContainer for WinForms provides the following control: C1SplitContainer To use SplitContainer for WinForms, add this control to the form or add a reference to the C1.Win.C1SplitContainer assembly in your project. Manually Adding SplitContainer for WinForms to the Toolbox When you install SplitContainer for WinForms, the following components will appear in the Visual Studio Toolbox customization dialog box: 1. 2. C1SplitContainer Open the Visual Studio IDE (Microsoft Development Environment). Make sure the Toolbox is visible (select Toolbox in the View menu if necessary) and right-click it to open the context menu. To make SplitContainer for WinForms component appear on its own tab in the Toolbox, select Add Tab from the context menu and type in the tab name, C1SplitContainer, for example. To manually add the SplitContainer for WinForms control to the Visual Studio Toolbox:

3. 4.

Right-click the tab where the component is to appear and select Choose Items from the context menu. The Choose Toolbox Items dialog box opens. In the dialog box, select the .NET Framework Components tab. Sort the list by Namespace (click the Namespace column header) and check the check boxes for all components belonging to namespace C1.Win.C1SplitContainer. Note that there may be more than one component for each namespace.

16

Adding C1SplitContainer to the Form To add C1SplitContainer to a form: 1. 2. Add the C1SplitContainer control to the Visual Studio Toolbox. Double-click the control or drag it onto your form.

Adding a Reference to the Assembly To add a reference to the C1SplitContainer assembly: 1. 3. 4. Select the Add Reference option from the Project menu of your project. Select the ComponentOne C1SplitContainer assembly from the list on the .NET tab or browse to find the C1.Win.C1SplitContainer.4.dll file and click OK. Double-click the form caption area to open the code window. At the top of the file, add the following Imports statements (using in C#): Imports C1.Win.C1SplitContainer

Note: This makes the objects defined in the C1SplitContainer assembly visible to the project. See Namespaces for more information.

17

Key Features
The following are some of the main features of C1SplitContainer that you may find useful: Expand and Collapse Panels Just set one property, Collapsible, to enable expandable or collapsible panels. See Collapsible and Expandable Panels (page 37) for more information.

Flexible Layout Options With just one property, Dock, you can create a complex interface by docking panels or nested panels to the top, bottom, left, or right of the container control. For more information see SplitContainer Layout (page 33).

Multiple Panels You can easily add, remove, and modify multiple panels through the C1SplitContainer.Panels Collection editor. For more information see Adding Multiple Panels to the C1SplitContainer (page 45).

Unlimited Nesting Organize massive amounts of data into one page using SplitContainers nesting feature. SplitContainer for WinForms enables you to nest multiple splits of any orientation type as well accommodate the resizing for the nested splitters when you resize the panel. See Compound Split (page 36) for more information.

Collapsed or Expanded Splitter Bar ToolTip Create a more user-friendly Windows application by adding a ToolTip to the collapsed or expanded splitter bar. The ToolTip can let end-users know to click on the expander button to expand the hidden panel or click on the collapsed button to hide the panel. See Expander Button (page 29) for more information.

19

SplitContainer for WinForms Quick Start


The goal of this quick start guide is to get you acquainted with SplitContainer for WinForms. In the first step of this Quick Start guide, you will add a C1SplitContainer control to your WinForms project. This quick start guide will also explain how to set the layout, behavior, and appearance properties of C1SplitContainer.

Step 1 of 4: Adding C1SplitContainer to the Page


In this step, you will create a .NET project and add a C1SplitContainer control to it. Complete the following steps: 1. 2. Begin by creating a new Windows Forms Application. For more information see Creating a .NET Project (page 15). While in Design view, navigate to the Visual Studio Toolbox and double-click the C1SplitContainer control to add it to your form. For more information see Adding the C1SplitContainer Component to a Project (page 16). The C1SplitContainer appears as a container with one C1SplitterPanel.

In the next step, you will add several C1SplitterPanels to the C1SplitContainer control.

20

Step 2 of 4: Adding C1SplitterPanels to the C1SplitContainer


In this step you learn how to add the C1SplitterPanels to the C1SplitContainer through the C1SplitContainer.Panels Collection editor as well as set the panels Dock property to control the layout of the panels. Complete the following steps: 1. 2. 3. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel from the C1SplitContainer Tasks Menu. One C1SplitterPanel is added below the existing one. Drag and drop another C1SplitContainer into Panel2 of the C1SplitContainer.

4. 5. 6.

Select C1SplitContainer2 and click Add Panel from its tasks menu to add a new C1SplitterPanel. Select C1SplitContainer1 and click Add Panel from its tasks menu to add a new C1SplitterPanel. Select C1SplitContainer1 Panel1 dock property to left.

7.

Select Panel 2 of C1SplitContainer1 and set its Dock property to left.

21

Panel2 which contains Panel1 and Panel2 of C1SplitContainer2 will be docked to the left of its parent control, Panel 3.

Step 3 of 4: Creating Collapsible Panels


In this step you will modify a few common elements of the C1SplitContainer control to change its appearance as well as create collapsible panels. Complete the following steps: 1. Select C1SplitContainer2 Panel1s smart tag and check collapsible.

22

The expander button appears and now you will be able to expand or collapse the panels of Panel 2 at run time. 2. Select C1SplitContainer1 to reveal its list of properties and then complete the following: 3. 4. 5. Set the C1SplitContainer1.BackColor property to LightSteelBlue. Set the C1SplitContainer1.FixedLineColor property to BlanchedAlmond. Set the C1SplitContainer1.HeaderBackColor property to Navy. Set the C1SplitContainer1.HeaderForeColor property to White. Set the C1SplitContainer1.SplitterColor property to BlanchedAlmond.

For more information see SplitContainer Appearance Properties (page 32). Set the C1SplitContainer1.Dock property to Fill. Select C1SplitContainer1 and click Edit Panels from its tasks menu. In the Members list select the c1SplitterPanel2 [Panel 2] and delete the default, Panel 2 text from the Text property. This removes the panel header from the C1SplitContainer. The appearance settings will be updated at design time, and your control will resemble the following image:

In the next step, you'll control the sizing for the C1SplitterPanels.

23

Step 4 of 4: Sizing the C1SplitContainer Control


In this step, you will create a fixed size and absolute size panel and run the project to see the effect of the panels sizing. Complete the following steps: 1. Select c1SplitterPanel1 of C1SplitContainer1 and set its following properties: 2. 3. Set the c1SplitterPanel1.Width property to 80. Set the c1SplitterPanel1.KeepRelativeSize property to False. Set the c1SplitterPanel1.Resizable property to False. Set the c1SplitterPanel1.Text property to Fixed.

Select c1SplitterPanel4 of the C1SplitContainer1 and set its the c1SplitterPanel4.MinWidth property to 80. Press F5 to build the project. Observe the following behaviors: Hover over the expander button and notice that a tooltip appears with the default text, minimize panel 1. Click the expander button and notice panel1 collapses. Notice how you cant resize the Fixed panel since you set the Resizable property to False. Click the splitter bar to activate it and then attempt to drag the splitter bar to the bottom of the control.

As you've probably noticed by now and as you can see in the image above you can't expand the bar all the way over to the right of the control. This is because you set the MinWidth to 80 so that users wouldn't be able to minimize Panel 3 to a width of less than 80 pixels. Thus, upon releasing your cursor, Panel 3 will appear no smaller than 80 pixels. What You've Accomplished Congratulations! You have successfully completed the C1SplitContainer quick start. In this topic, you added a C1SplitContainer control to your window page, added panels, customized its behavior and appearance, and manipulated the control at run time.

Design-Time Support
C1SplitContainer provides customized context menus, smart tags, and a designer that offers rich design-time support and simplifies working with the object model.
24

The following topics describe how to use C1SplitContainer design-time environment to configure C1SplitContainer.

C1SplitContainer Smart Tags


In Visual Studio, each component in SplitContainer for WinForms includes a smart tag. A smart tag represents a short-cut tasks menu that provides the most commonly used properties in each control. The following section introduces each smart tag for C1SplitContainers components.

C1SplitContainer Tasks Menu


To access the C1SplitContainer Tasks menu, click the smart tag ( ) in the upper right corner of the C1SplitContainer control. This will open the C1SplitContainer Tasks menu.

The C1SplitContainer Tasks menu operates as follows: Add Panel Clicking the Add Panel item adds a new C1SplitterPanel beneath the existing one. Edit Panels Clicking the Edit Panels item opens the C1SplitContainer.Panels Collection Editor where you can add, remove, or modify C1SplitterPanels. Visual Style The Visual Style dropdown box provides a list of styles to choose from: Custom, System, Office2007Black, Office2007Blue, Office2007Silver, Office2010Black, Office2010Blue, Office2010Silver, and Windows7. Splitter Width Specifies the width of the splitter element. The default splitter width is 4 pixels. Splitter Color Click the dropdown arrow and select a color to specify the background color for the splitter element.

25

Fixed Line Color Click the dropdown arrow and select a color to specify the fixed line background color for the C1SplitContainer. Border Width Specifies the width of the C1SplitContainer border, in pixels. The default Border width is 1 pixel. Header Height Specifies the height of each C1SplitterPanel header. The default height is 21 pixels. Line Below Header Unchecking the checkbox removes the line below the header item. About C1SplitContainer Clicking About C1SplitContainer reveals the About ComponentOne dialog box. This dialog box displays the version number and licensing information for the ComponentOne SplitContainer product.

C1Splitter Panel Tasks Menu


To access the C1SplitterPanel Tasks menu, click the smart tag ( ) in the upper right corner of the C1SplitterPanel component. This will open the C1SplittePanel Tasks menu.

The C1SplitterPanel Tasks menu operates as follows: Text Specifies the name that appears in the Header element of the C1SplitterPanel. Text Align Click on the dropdown arrow to specify the alignment of the header text: Left, Center, and Right. Dock Click on the dropdown arrow to specify the dock position of the C1SplitterPanel: Top, Bottom, Left, or Right. Keep Relative Size Unchecking this checkbox sets the KeepRelativeSize property to False. Resizable Unchecking this checkbox sets the Resizable property to False. If set to False, the panel will not be resized with a splitter.

26

Resize While Dragging Splitter Indicates whether or not to resize the panel while the user is dragging the splitter. By default the checkbox is unchecked so the user cant resize the panel while dragging the splitter. Collapsible Indicates whether or not the C1SplitterPanel can be collapsed. Check this checkbox to make the C1SplitterPanel collapsible. By default the panel is not collapsible.

SplitContainer Elements
The topics in this section are categorized into distinct elements that represent different aspects of the C1SplitContainer control. Each individual topic provides the following information: The elements purpose and its position within a control. The elements essential parts. The elements properties that affect the appearance and functionality of the element.

Four elements exist within the C1SplitContainer control: a C1SplitterPanel, Splitter Bar, SplitterPanel Header, and an expander button. The C1SplitContainer represents a container to hold the panels and its elements. The Splitter Bar represents the divider that separates the two panels. The C1SplitterPanel represents the panel inside the C1SplitContainer. The Panel Header represents the header that appears as a rectangular title bar above each panel. By default, a fixed line appears below the panel header and its color and width can be controlled by the FixedLineColor and FixedLineWidth properties. The expander button appears when the Collapsible property is true. The following image labels the elements of the C1SplitContainer control:

Splitter Panels
The default C1SplitContainer has 1 panel. One or more panels can be added to the C1SplitContainer at design time through the C1SplitContainers Tasks menu or properties window or programmatically through the Add method. When a second panel is added it appears below the previous panel and a horizontal splitter bar separates the two panels.

27

Arbitrary controls can be added within each panel. In the C1SplitContainer.Panels Collection editor, you can add, remove, and edit each panel's appearance and behavior through the C1SplitterPanel properties included in it. In the object model for C1SplitContainer, all panels are referred as the C1SplitterPanel. The C1SplitterPanel object contains properties and methods for all panels. You can apply different behaviors and styles to each panel since you can set each panel individually.

Panel Header
The Panel Header represents the header that appears as a rectangular title bar above each panel. By default, a fixed line appears below the panel header and its color and width can be controlled by the FixedLineColor and FixedLineWidth properties. A panel header can be removed by deleting the text from the Text property. The following table lists and describes the properties that effect the panel header:
Property HeaderBackColor HeaderForeColor HeaderTextAlign Text FixedLineColor FixedLineWidth LineBelowHeader HeaderHeight HeaderTextOffset Description Gets the background color of the header in the C1SplitterPanel. Gets the foreground color of the header in the C1SplitterPanel. Gets the text alignment for the header in the C1SplitterPanel. Gets the text for the header in the C1SplitterPanel. Gets or sets the color of a fixed dividing line. Gets or sets the width of a fixed dividing line. Gets or sets whether a horizontal line should appear below panel headers. Gets or sets the height of the C1SplitterPanel header. Gets or sets the offset value (in pixels) of the panel caption text.

For more information see SplitContainer Appearance Properties (page 32).

28

Splitter Bar
The Splitter Bar represents the divider that separates the two panels. The splitter bar appears when two or more panels are added to the C1SplitContainer control. The following table lists and describes the properties that effect the splitter bar:
Property SplitterColor SplitterWidth SplitterMovingColor SplitterMovingOpacity Description Gets or sets the color of a splitter element. Gets or sets the width of a splitter element. Gets or sets the opacity level of a splitter being moved by the user. Gets or sets the opacity level of a splitter being moved by the user.

For more information see SplitContainer Appearance Properties (page 32).

Expander Button
The expander button appears on the splitter bar of the C1SplitContainer when the Collapsible property is True. When the panel is expanded the arrow points up and when the panel is collapsed the arrow points down. You can make the expander button appear larger by setting the EnlargeCollapsingHandle property to True. The expander button image and the splitter bar will appear different depending on the visual style applied to the control. Appearance of the Splitter Bar Styles The following image illustrates the Collapsible property set to True:

The following image illustrates the Collapsible property set to True and the EnlargeCollapsingHandle property set to True:

29

SplitContainer Appearance
The following topics describe C1SplitContainers built-in visual styles and appearance properties.

SplitContainer Visual Styles


C1SplitContainer provides eight built-in visual styles for the control System, Office2007Black, Office2007Blue, Office2007Silver, Office2010Black, Office2010Blue, Office2010Silver, and Windows7 - that can be easily applied to the control by setting the VisualStyle property. The visual styles change the appearance of all of the elements of the C1SplitContainer such as the C1SplitterPanel, splitter bar, expander button, and panel header. There is no built-in Custom visual style in the C1SplitContainer. Any style which doesn't match the predefined styles is considered as Custom. If you want to use a Custom style you should assign custom values to any of the following properties: BackColor, ForeColor, ToolTipGradient, CollapsingAreaColor, CollapsingCueColor, SplitterColor, FixedLineColor, HeaderBackColor, and HeaderForeColor. Then, the value of the VisualStyle property changes automatically to the Custom value. Actually, the VisualStyle property is just an indicator, it's not persistable. The value of this property depends on the other properties (listed above). To learn how to set the VisualStyle property, see Changing the Visual Style (page 51). The following table illustrates each of the eight built-in visual schemes.
Formatting System Appearance

Office2007Black

30

Office2007Blue

Office2007Silver

Office2010Black

Office2010Blue

31

Office2010Silver

Windows7

SplitContainer Appearance Properties


This section describes a few of C1SplitContainer and C1SplitterPanels main appearance properties along with a C1SplitContainer showing the effect of each property setting on the C1SplitContainer.

The following table describes each of the C1SplitContainer appearance properties used in the image above:

32

Property

Description Gets the background color of the C1SplitContainer control. Gets the width of the splitter element. Gets the color of the splitter element. Gets the color of the fixed dividing line. Gets the width of the fixed dividing line.

C1SplitContainer.BackColor
SplitterWidth SplitterColor FixedLineColor FixedLineWidth

The following table describes each of the C1SplitterPanel appearance properties used in the image above:
Property HeaderBackColor HeaderForeColor HeaderTextAlign Text Description Gets the background color of the header in the C1SplitterPanel. Gets the forecolor of the header in the C1SplitterPanel. Gets the text alignment for the header in the C1SplitterPanel. Gets the text for the header in the C1SplitterPanel.

For task-based help on modifying the C1SplitterPanels appearance, see Changing the C1SplitContainers Appearance (page 47).

SplitContainer Layout
C1SplitContainer has a WYSIWYG editor that allows you to view the end result without having to run the project. With the WYSIWYG designer interface C1SplitContainer supports, it makes it simple to arrange child controls in the containers of the panels because C1SplitContainer displays them as it would at run time. You can add as many child controls to each panel by dragging and dropping each control into the desired panel. Panels can be selected on the Form by clicking anywhere inside the rectangular box. The WYSIWYG designer interface makes it simple to add child controls to a specific splitter panel via drag and drop. You also can add child controls programmatically to a specific splitter panel through the C1SplitterPanel object since it is a control. To add a C1SplitterPanel programmatically to a specified panel, use the following code: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add panel1 to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2)

33

Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); Controls.Add(split); } For more information on adding multiple panels to the C1SplitContainer see, Adding Multiple Panels to the C1SplitContainer (page 45).

SplitContainer Layout Options


The default C1SplitContainer has a simple horizontal layout. The horizontal layout has one panel with a header. The default C1SplitterPanel appears docked to the top. When another C1SplitterPanel is added it appears below the initial C1SplitterPanel.

The C1SplitterPanels layout can easily be controlled by the Dock property. The C1SplitterPanels can be docked to the top, left, right or bottom on the container that the C1SplitterPanel has been assigned to. Use the Dock property to define how a C1SplitterPanel is automatically resized as its parent control is resized. For example, setting the Dock to Left causes the panel to align itself with the left edges of its parent control and to resize as the parent control is resized. If Left, Right, Top, or Bottom is selected, the specified and opposite edges of the control are resized to the size of the containing C1SplitContainer's corresponding edges. The PanelDockStyle settings are:
Member Name Description The C1SplitterPanels top edge is docked to the top of its containing C1SplitContainer. The C1SplitterPanels bottom edge is docked to the

Top Bottom

34

bottom of its containing C1SplitContainer.

Left Right

The C1SplitterPanels left edge is docked to the left edge of its containing C1SplitContainer. The C1SplitterPanels right edge is docked to the right edge of its containing C1SplitContainer.

The last visible panel in the Panels collection is the special case. It always behaves as if its Dock property is set to Fill (all four sides of the control are resized to match the containing controls edges). Values of the following properties are ignored for the last visible panel: Collapsible, ResizeWhileDragging, Dock, SizeRatio, KeepRelativeSize, and Resizable. Also, an attempt to change the Width or the Height property of such a panel has no visible effect. If this panel becomes not the last, or if any of the subsequent panels becomes visible, all the mentioned properties start to work as one may expect. C1SplitterPanels Dock property makes it easy to create the following splits in the C1SplitContainer: Horizontal Split Vertical Split Nested Split Full Split

Horizontal Split
A horizontal split is the default split type for the C1SplitContainer. It divides the panels into two or more rows and is represented in the windows page by one or more splitter bars. In a horizontal split the panels are both docked to the top. The following image illustrates a horizontal split:

For task-based help on creating a horizontal split, see Creating a Horizontal Split (page 54).

Vertical Split
A vertical split divides the panels into two or more columns and is represented in the Window page by one or more splitter bars. The following image illustrates a vertical split:

35

For task-based help on creating a vertical split, see Creating a Vertical Split (page 56).

Compound Split
A compound split is a nested split, meaning that the initial C1SplitContainer control contains one or more C1SplitContainer controls. A compound split can contain two or more vertical splitters, two or more horizontal splitters, or a combination of vertical and horizontal splitters. A compound split can be created by added two or more C1SplitterPanels into the panel of the parent C1SplitContainer. For more information on creating a compound split, see Creating a Nested Split (page 58). The following image illustrates a compound split:

For task-based help on creating a compound split, see Creating a Nested Split (page 58).

Full-Size Split
A full-size split is a horizontal or vertical split that stretches to fill the content area of a window. The following image illustrates a full-size split:

36

To create a full-size split, set the C1SplitContainer.Dock property to Fill. For task-based help on creating a fullsize split, see Creating a Full-Size Split (page 58).

SplitterPanel Behavior
The following section details the behavior properties used to control the behavior of the splitter panels.

Collapsible and Expandable Panels


The panels in C1SplitContainer can easily be collapsed or expanded by setting the Collapsible property to True (see Adding a ToolTip to the Collapsed Splitter Panel (page 60)). Once the property is set, you can click on the expander button to collapse or expand the panels. The following image illustrates Panel1's Collapsible property set to True:

When the Collapsible property is set to True you can enter text for the collapsed or collapsing tooltip using the CollapsedToolTip and CollapsingToolTip properties. The following image shows the default tooltip when you hover over the expanded button:

37

When you hover over the expander button of a minimized panel the default tooltip text will read, expand panel.

SplitterPanel Scrolling
The panels in the C1SplitContainer control are scrollable by default.

To disable scrolling in a specific panel, set the C1SplitterPanel.AutoScroll to False.

SplitterPanel and Splitter Bar Sizing


You can determine the panel's minimum size as well as determine how the panels size when you move the splitter bar. Controlling the Panel Size You have complete control over the size of the panels in the C1SplitContainer control. You can specify the minimum width or height of each panel to prevent the user from resizing it too small through the MinWidth property (see Setting a Minimum Size for a Splitter Panel (page 61)). This allows more flexibility in the interface for the designer and prevents important information from being hidden. Splitter Bar Width You can specify the width of your divider through the SplitterWidth property. To create a more defined split, you can increase the width of your splitter bar. The default splitter width size is 4 pixels.

38

OwnerDraw Panel Header and Splitter


If you want to draw the custom header for a C1SplitterPanel or draw the custom Splitter Bar you can use the DrawHeader and DrawSplitter events. The DrawHeader event is fired when the C1SplitContainer control needs to repaint the header of the specified C1SplitterPanel. The clipping region is restricted by the panel header area. The DrawSplitter event is fired to draw the splitter element (the user can drag this element to resize the panel). The clipping region is restricted by the splitter element. You can take a look at the LayoutDemo sample for an example of using both events.

SplitContainer for WinForms Samples


Please be advised that this ComponentOne software tool is accompanied by various sample projects and/or demos which may make use of other development tools included with the ComponentOne Studios. You can access samples from the ComponentOne SplitContainer. To view samples, click the Start button and then click ComponentOne | Studio for WinForms | SplitContainer. The following table provides a short overview of each sample.
Sample VisualStyles LayoutDemo Description Illustrates C1SplitContainers built-in visual styles. Demonstrates different layout options for the C1SplitterPanels such as fixed, nested, and absolute panels.

39

SplitContainer for WinForms TaskBased Help


The task-based help section assumes that you are familiar with programming in the Visual Studio NET environment and have a general understanding of the ComponentOne SplitContainer control. Each topic provides a solution for specific tasks using the C1SplitContainer control. By following the steps outlined in each topic, you will be able to create projects using a variety of C1SplitContainer features.

Adding Content to the Splitter Panels


A C1SplitContainer control can hold arbitrary controls or display text. The following topics will instruct you on adding content to the pages of your C1SplitContainer control.

Adding Arbitrary Controls to the C1SplitterPanel


You can add arbitrary controls to each C1SplitterPanel of the C1SplitContainer control using a simple drag-anddrop operation. In this topic, you will add a Button control to Panel1 and a TextBox control to Panel2. In Design View Complete the following steps: 1. 2. 3. 4. 5. Add C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel twice to add two panels to the C1SplitContainer control. Click inside Panel 1 and open its tasks menu. The C1SplitterPanel Tasks menu appears. Select a Button control from the Visual Studio Toolbox and drag it into the Panel 1. Select a TextBox control from the Visual Studio Toolbox and drag it into Panel 2. In Code Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

3.

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) ' Create a Button control and add text to it Dim button1 As New Button() button1.Text = "Hello World!"

41

' Create a TextBox control Dim textbox1 As New TextBox() 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add panel1 to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" 'add the splitcontainer Controls.Add(split) 'add the button control to panel1 panel1.Controls.Add(button1) 'add the textbox control to panel2 panel2.Controls.Add(textbox1) End Sub C# private void Form1_Load(object sender, EventArgs e) { // Create a Button control and add text to it Button button1 = new Button(); button1.Text = "Hello World!"; // Create a TextBox control TextBox textbox1 = new TextBox(); //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //add the splitcontainer Controls.Add(split); //add the button control to panel1

42

panel1.Controls.Add(button1); //add the textbox control to panel2 panel2.Controls.Add(textbox1); } 4. Run the program.

This Topic Illustrates the Following: The following graphic depicts a C1SplitContainer control with a Button control in Panel1 and a TextBox control in Panel2.

Adding Text to a Splitter Panel


In this topic, you will learn how to add text to a C1SplitContainer control in design view and in code. In Design View To add text to a panel, add a RichTextBox control to panel1, add text to the RichTextBox control and then set the Dock property to Fill. 1. 2. 3. 4. 5. 6. 7. 8. In Code Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: Visual Basic Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel once to add another panel to the C1SplitContainer control. Click inside Panel 1 and open its tasks menu. The C1SplitterPanel Tasks menu appears. Select a RichTextBox control from the Visual Studio Toolbox and drag it into the Panel 1. Set the RichTextBox1.Text property to "A lighthouse is a building to help aid pilots in navigation while at sea or on inland waterways." Set the RichTextBox1.Dock property to Fill. Set the RichTextBox1.ForeColor property to "DarkBlue".

43

using C1.Win.C1SplitContainer; 3. C# Imports C1.Win.C1SplitContainer

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) Dim richtextbox1 As New RichTextBox() richtextbox1.Text = "A lighthouse is a building to help aid pilots in navigation while at sea or on inland waterways." richtextbox1.ForeColor = Color.DarkBlue richtextbox1.Dock = DockStyle.Fill 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add panel1 to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" 'add the splitcontainer Controls.Add(split) 'add the button control to panel1 panel1.Controls.Add(richtextbox1) End Sub C# private void Form1_Load(object sender, EventArgs e) { RichTextBox richtextbox1 = new RichTextBox(); richtextbox1.Text = "A lighthouse is a building to help aid pilots in navigation while at sea or on inland waterways."; richtextbox1.ForeColor = Color.DarkBlue; richtextbox1.Dock = DockStyle.Fill; //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //add the splitcontainer

44

Controls.Add(split); //add the button control to panel1 panel1.Controls.Add(richtextbox1); } 4. Run the program.

This Topic Illustrates the Following: The following graphic depicts a C1SplitContainer control with a RichTextBox control docked within Panel 1.

Adding Multiple Panels to the C1SplitContainer


In this topic, you will learn how to add multiple C1SplitterPanels to the C1SplitContainer control in design view and in code. In Design View Complete the following steps: 1. 2. 3. 4. Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Edit Panels from the C1SplitContainer Tasks Menu. The C1SplitContainer.Panels Collection Editor appears. Click on the Add button twice to add two more C1SplitterPanels to the C1SplitContainer. Once a C1SplitterPanel is added to the C1SplitContainer the properties appear in the right pane so you can easily modify the C1SplitterPanels settings. Click OK to save and close the C1SplitContainer.Panels Collection Editor.

5. In Code

Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

45

3.

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new Dim panel1 As Dim panel2 As Dim panel3 As panel for the split container New C1SplitterPanel() New C1SplitterPanel() New C1SplitterPanel()

'add the panels to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) split.Panels.Add(panel3) panel1.Text = "Panel 1" panel2.Text = "Panel 2" panel3.Text = "Panel 3" 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for C1SplitterPanel panel1 = C1SplitterPanel panel2 = C1SplitterPanel panel3 = the new new new split container C1SplitterPanel(); C1SplitterPanel(); C1SplitterPanel();

//add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); split.Panels.Add(panel3); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; panel2.Text = "Panel 3"; //add the splitcontainer Controls.Add(split); } 4. Run the program.

This Topic Illustrates the Following: The following graphic depicts a C1SplitContainer control with three C1SplitterPanels.

46

Changing the C1SplitContainers Appearance


The following topics detail how to modify the appearance of a C1SplitContainer control using the C1SplitContainer and C1SplitterPanel properties.

Changing the Background Color of Panels


You can quickly set the background color of the C1SplitterPanels using the C1SplitterPanel.BackColor property. In this topic, you'll learn how to apply different colors to each panel of the C1SplitContainer control in design view and in code. In Design View Complete the following steps: 1. 2. 3. 4. Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Edit Panels from the C1SplitContainer Tasks Menu. The C1SplitContainer.Panels Collection Editor appears. Click Panel 1s BackColor drop-down arrow, select the Web tab, and choose LightBlue from the list and click OK to save and close the C1SplitContainer.Panels Collection Editor.

47

In Code: Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: 3. Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() 'add the panel to the splitcontainer split.Panels.Add(panel1) panel1.Text = "Panel 1" set Panel 1 backcolor to lightblue Panel.BackColor = Color.LightBlue

48

'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); panel1.Text = "Panel 1"; //set Panel 1 backcolor to lightblue Panel.BackColor = Color.LightBlue; //add the splitcontainer Controls.Add(split); } 4. Run the program.

This Topic Illustrates the Following: The image below shows Panel 1 with a LightBlue background.

Changing the Border Color


By default, the color of the C1SplitContainer border is determined by its visual style; however, you can change the color of that border using the BorderColor property. In this topic, you will learn how to set the BorderColor property in design view and in code. In Design View: Complete the following steps: 1. Add the C1SplitContainer to the form.

49

2.

In the C1SplitContainer Properties window set the BorderColor property to Black. The border color is updated on the C1SplitContainer control.

In Code: Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: 3. Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() set splitcontainer border color to black split.BorderColor = Color.Black 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //set splitcontainer border color to black split.BorderColor = Color.Black; //add the splitcontainer Controls.Add(split); }

4.

Run the program.

This Topic Illustrates the Following: The image below shows the C1SplitContainer with a black border.

50

Changing the Visual Style


C1SplitContainer features eight embedded visual styles that you can apply to the control with just a few clicks. This topic illustrates how to change the control's visual style in Design view, Source view, and in code. For more information on visual styles, see SplitContainer Visual Styles (page 30). In Design View Complete the following steps: 1. 2. Click C1SplitContainer's smart tag to open the C1SplitContainer Tasks menu. Click the VisualStyle drop-down arrow and then select a visual style from the list. For this example, choose Office2010Blue.

The C1SplitContainer control adopts the Office2010Blue visual style. In Code Complete the following steps: 1. Add the C1.Win.C1SplitContainer.dll reference to your project.

51

2.

Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

3.

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() set splitcontainer visual style to office2010blue split.VisualStyle = VisualStyle.Office2010Blue 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //set splitcontainer visual style to office2010blue split.VisualStyle = VisualStyle.Office2010Blue //add the splitcontainer Controls.Add(split); }

4.

Run the program.

This Topic Illustrates the Following: The following image shows a C1SplitContainer with the Office2010Blue visual scheme:

Changing the Splitter Width


You can easily widen the splitter bar using the SplitterWidth property. In this topic, you will learn how to set the SplitterWidth property in design view and in code.

52

In Design View Complete the following steps: 1. 2. 3. 4. In Code Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: 3. Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel once to add another panel to the C1SplitContainer control. In the C1SplitContainer Properties window, set the SplitterWidth property to 40.

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add the panels to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" set the splitter width to 40 pixels Split.SplitterWidth = 40 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2);

53

panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //set the splitter width to 40 pixels split.SplitterWidth = 40; //add the splitcontainer Controls.Add(split); } 4. Run the program.

This topic illustrates the following: The following image displays a vertical C1SplitContainer with its SplitterWidth property set to 40 pixels:

Creating Different Split Types


There are four types of splits that can be created with the C1SplitContainer control: horizontal split, vertical split, nested split, and full-size split. This section contains procedures for creating each type of split. For more information on split types, see SplitContainer Layout (page 33).

Creating a Horizontal Split


Creating a horizontal split is as simple as setting one property. In this topic, you'll learn how to set the C1SplitContainer.Dock property in design view and in code. For more information on horizontal splits, see Horizontal Split (page 35). In Design View Complete the following steps: 1. 2. 3. 4. In Code Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel once to add another panel to the C1SplitContainer control. A new panel is added below and the panels appear horizontal, by default. In the C1SplitterPanels Properties Window or the C1SplitterPanel Tasks menu and locate the Dock property and notice the Dock property is set to Top by default.

54

Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: 3. Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add the panels to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //add the splitcontainer Controls.Add(split); }

4.

Run the program.

This topic illustrates the following: The splitter bar and panels appear horizontal. The result of this topic will resemble the following image:

55

Creating a Vertical Split


Creating a vertical split is as simple as setting one property. In this topic, you'll learn how to set the Dock property in design view and in code view. For more information on vertical splits, see Vertical Split (page 35). In Design View Complete the following steps: 1. 2. 3. 4. Add the C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel once to add another panel to the C1SplitContainer control. A new panel is added below and the panels appear horizontal, by default. Select Panel 1 and set its Dock property to Left so it moves the panel to the left side and moves the splitter bar vertically.

In Code Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: Visual Basic using C1.Win.C1SplitContainer;

56

3.

C# Imports C1.Win.C1SplitContainer

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add the panels to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" panel1.Dock = DockStyle.Left 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel(); //add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //dock panel 1 to the left Panel1.Dock = DockStyle.Left; //add the splitcontainer Controls.Add(split); }

4.

Run the program.

This Topic Illustrates the Following: The splitter bar is now vertical. The final result of this topic will resemble the following image:

57

Creating a Nested Split


You can combine multiple C1SplitContainer objects to create nested splits. In this topic, you will learn how to nest a horizontal split within the first panel of a vertical split. For more information on nested splits, see Compound Split (page 36). Complete the following steps: 1. 2. 3. 4. 5. 6. Add the C1SplitContainer control to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel twice to add two more C1SplitterPanels to the C1SplitContainer control. Select Panel 2s smart tag and set its Dock property to Left. Add another C1SplitContainer onto Panel 2 and add select Add Panel to add another C1SplitterPanel to C1SplitContainer2. Select Panel 1s smart tag in C1SplitContainer2 and set its Dock property to Left.

This Topic Illustrates the Following: The following image displays C1SplitContainer2 nested within the bottom left panel of C1SplitConainer1:

Creating a Full-Size Split


A full-size split is a horizontal or vertical split that stretches to fill the content area of a Windows Form. You can create a full-size split by setting one property: C1SplitContainer.Dock to Fill. In this topic, you'll learn how to set the C1SplitContainer.Dock property in design view and in code.

58

For more information on full-size splits, see Full-Size Split (page 36). In Design View Complete the following steps: 1. 2. 3. 4. 5. In Code Complete the following steps: 1. 2. Add the C1.Win.C1SplitContainer.dll reference to your project. Declare the following C1.Win.C1SplitContainer namespace at the top of your code page: 3. Visual Basic using C1.Win.C1SplitContainer; C# Imports C1.Win.C1SplitContainer Add C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel once to add one more C1SplitterPanel to the C1SplitContainer control. Select C1SplitContainer1 from the Properties list dropdown box and set its C1SplitContainer.Dock property to Fill. Run the program and observe that the control expands to the width and height of your Windows form.

Add the following code in the Form_Load event: Visual Basic Private Sub Form1_Load(sender As Object, e As EventArgs) 'create new splitcontainer Dim split As New C1SplitContainer() 'create a new panel for the split container Dim panel1 As New C1SplitterPanel() Dim panel2 As New C1SplitterPanel() 'add the panels to the splitcontainer split.Panels.Add(panel1) split.Panels.Add(panel2) panel1.Text = "Panel 1" panel2.Text = "Panel 2" split.Dock = DockStyle.Fill 'add the splitcontainer Controls.Add(split) End Sub C# private void Form1_Load(object sender, EventArgs e) { //create new splitcontainer C1SplitContainer split = new C1SplitContainer(); //create a new panel for the split container C1SplitterPanel panel1 = new C1SplitterPanel(); C1SplitterPanel panel2 = new C1SplitterPanel();

59

//add panel1 to the splitcontainer split.Panels.Add(panel1); split.Panels.Add(panel2); panel1.Text = "Panel 1"; panel2.Text = "Panel 2"; //create a full size split split.Dock = DockStyle.Fill; //add the splitcontainer Controls.Add(split); } 4. Run the program and observe that the control expands to the width and height of your Window Form.

This Topic Illustrates the Following: The C1SplitContainer expands to the width and height of your Window Form.

Setting C1SplitContainer Behaviors


The C1SplitContainer control has a list of properties that affect how the control behaves at run time. Some of the properties affect how the control acts when loaded, whereas others affect the users' interactions with the control. The following topics will instruct you on how to modify the run-time actions of the control.

Adding a ToolTip to the Collapsed Splitter Panel


To add a ToolTip to display text when you hover over the collapsed splitter bar, simply set CollapsedToolTip property. In this topic, you will learn how to set the CollapsedToolTip property in design view and in code. For more information on ToolTips, see Collapsible and Expandable Panels (page 37). In Design View Complete the following steps: 1. 2. Add C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu.

60

3. 4. 5. 6. In Code

Select Add Panel to add a panel to the C1SplitContainer control. Click inside Panel1 and open its tasks menu. The C1SplitterPanel Tasks menu appears. Check Collapsible to make Panel1 collapsible and expandable. Right-click inside Panel1and select Properties. In the Properties window, set the CollapsedToolTip to Click the button to expand Panel 1.

Complete the following steps: 1. Import the following namespace into your project: Visual Basic Imports C1.Win.C1SplitContainer C# using C1.Win.C1SplitContainer;

2.

Add the following code, which sets the CollapsedToolTip property, to the Page_Load event: Visual Basic Panel1.CollapsedToolTip = "Click the button to expand Panel 1." C# Panel1.CollapsedToolTip = "Click the button to expand Panel 1.";

3.

Run the program.

This Topic Illustrates the Following: After you've built the project, click the button to collapse panel1 and then hover over the splitter bar and observe that a ToolTip has been added to the collapsed splitter bar. The result will resemble the following image:

Setting a Minimum Size for a Splitter Panel


In some instances, you might want to keep users from resizing a panel past a certain point. In Panel1, for example, you may have a stack of buttons that you want visible at all times. When confronted with that sort of situation, you can use the MinWidth property to specify, in pixels, the size of the area that you don't want users to drag past. In this topic, you will learn how to set the MinWidth property in Design view and in Code view. For more information on panel sizing, see SplitterPanel and Splitter Bar Sizing (page 38).

61

In Design View Complete the following steps: 1. 2. 3. 4. 5. Add C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel to add a panel to the C1SplitContainer control. Click inside Panel 1 and open its tasks menu. The C1SplitterPanel Tasks menu appears. Right-click inside Panel 1and select Properties. In the Properties window, set the MinWidth property for Panel 1 to "30".

In Code View Complete the following steps: 1. Declare the following namespace into your project: Visual Basic Imports C1.Win.C1SplitContainer C# using C1.Win.C1SplitContainer;

2.

Add the following code, which sets the MinWidth property, to the Page_Load event: Visual Basic Panel1.MinSize = 30 C# Panel1.MinSize = 30;

3.

Run the program.

This Topic Illustrates the Following: Once you've built the project, drag the splitter bar to the left and observe that it remains at 30 pixels.

Setting a Collapsible Splitter Panel


To create a collapsed panel, use the Collapsible property. In this topic, you will learn how to set the Collapsible property in design view and in code. For more information on collapsed and expanded panels, see Collapsible and Expandable Panels (page 37). In Design View Complete the following steps: 1. 2. 3. 4. Add C1SplitContainer to the form. Click on the C1SplitContainers smart tag to open its tasks menu. Select Add Panel to add a panel to the C1SplitContainer control. Click inside Panel 1 and open its tasks menu. The C1SplitterPanel Tasks menu appears.

62

5. In Code

Check Collapsible to make Panel 1 collapsible and expandable.

Complete the following steps: 1. Declare the following namespace into your project: Visual Basic Imports C1.Win.C1SplitContainer C# using C1.Win.C1SplitContainer;

2.

Add the following code, which sets the Collapsible property, to the Form_Load event: Visual Basic Panel1.Collapsible = True C# Panel1.Collapsible = true;

3.

Run the program.

This topic illustrates the following: Panel1 is collapsed.

63

To expand the panel, simply click the expand button.

64

Das könnte Ihnen auch gefallen