codemorphis.com Forum Index codemorphis.com
Software development: pure and simple.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programming Tip #6: Using Splitters

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum
View previous topic :: View next topic  
Author Message
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Tue Feb 24, 2004 7:06 pm    Post subject: Programming Tip #6: Using Splitters Reply with quote

Programming Tip #6: Using Splitters

Splitter UI components are used to divide a Windows Form or a container UI component such as a Panel, GroupBox or TabPage. They allow the user of your program to change the amount of space allocated to segments of your interface. You see Splitters used in many Windows programs.

To see an example of Splitters in action, consider the Windows Form below:



In this example, we see two Splitters being used. The first Splitter (Splitter 1) divides the Windows Form between the ListBox on the left and the TabControl on the right. The second Splitter (Splitter 2) divides the TabPage "TabPage 1" into two with the TextBox on the top and the TreeView on the bottom.

When using Splitters, the order of the UI components is important. A Splitter should be added in between the two UI components that it should separate. So, if you want to create a simple Windows Form with say, a TextBox and a ListBox, where each occupies a portion of the Windows Form and the two are separated with a Spliter, then you would arrange the order as follows: 1) TextBox, 2) Splitter, 3) ListBox.

Let's see how this is done by constructing the Windows Form shown above.

  1. Open the Component Tray in Synopsis and drag and drop a "Windows Form" component onto the workspace area.
  2. Select the "UI Components" tab in the Component Tray and drag and drop a ListBox component onto the Windows Form.
  3. Double click the ListBox and in the property dialog that appears, look for the "Dock" property and set it "Left". Double click in the "Items List" property field and add some items. The Windows Form should look like:


  4. From the "UI Components" tab of the Component Tray, drag and drop a Splitter component onto the Windows Form. By default the Splitter has the dock property set to Left.
  5. Drag and drop a TabControl component onto the Windows Form. Double click the TabControl and set its Dock property to "Fill". Be careful in selecting the TabControl component and not the TabPage component that is contained by the TabControl and added by default. To know that it is the TabControl component that is selected, look at the title of the property dialog. It should read: "TabControl Property Page". Now our Windows Form looks as follows:

    I have added a second TabPage to the TabControl by dragging and dropping a TabPage component from the Component Tray onto the TabControl.
  6. Drag and drop a TextBox onto the TabPage "TabPage 1". Double click the TextBox and set its Dock property to "Top". Also set it's Multiline property to true by clicking on the associated checkbox.
  7. Drag and drop a Splitter onto "TabPage 1". Right click on the Windows Form and select "Browse/Select UI Component". Select the second splitter by double clicking on "Splitter 2" in the list. In the property page that opens for "Splitter 2", set the Dock property to "Top" and set the Cursor property to "HSplit", which makes the cursor appear as a horizontal splitter icon when the user hovers the mouse over the Splitter.
  8. Drag and drop a TreeView component onto "TabPage 1". Double click the TreeView and set its Dock property to "Fill". You can add some items to the TreeView in the "Items" property section.


Complete the Synopsis program as below (consult previous programming tips for details on creating Synopsis programs). You can also get the Synopsis source file for this program at http://www.codemorphis.com/articles/tip6/Splitter.vpd



As mentionned above, the order of the UI components is important in determining which components are "split" by the Splitter. To change the order of components you can right click on a component and then use the "Bring to front" and "Send to back" options to reorder the components.

Another important point is that Splitters can be added to the component lists of a Windows Form, a TabPage, a Panel or a GroupBox. Each one of these UI components is called a container component because each one can contain other UI components. By dragging and dropping a Splitter onto a container component, you specify that the Splitter is to separate only those components in the given container component.

http://www.codemorphis.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group