PB Treeview attributes and event details

Source: Internet
Author: User

This article from: http://chbin95233.blog.163.com/blog/static/32075111201010573448815/

■ The Treeview control can be used to organize projects in a tree-like manner. It not only provides intuitive display and user-friendly interfaces, but also facilitates project management and operations. It is currently a popular control.
This control allows you to display a large amount of data in a small space and retrieve data according to user requirements. This control has the following functions:
You can traverse data by expanding or folding nodes.
Graphical and visualized node display.
Drag and Drop operation.
This includes cutting, copying, and pasting node operations.

■ Typical Programming
The Treeview control is usually used to allow users to select data or manage data. For example, in a human affairs management software, it is easy to search for data using a three-layer structure such as department, surname, and name, and the personnel unit can be changed by dragging.
First, create the control when the window is opened. The following script first adds the highest level project to the Treeview control:
Treeviewitem ltvi_item
Ltvi_item.children = true
Ltvi_item.selectedpictureindex = 1
Ltvi_item.label = "Food and Beverage department"
Ltvi_item.data = "Food and Beverage department"
Ltvi_item.pictureindex = 1
TV _1.insertitemlast (0, ltvi_item)
Ltvi_item.label = "reception department"
Ltvi_item.date = "reception department"
Ltvi_item.pictureindex = 2
TV _1.insertitemlast (0, ltvi_item)

The above script adds all level-1 projects. You can use the above script repeatedly until all level-1 projects are added. Because these first-level projectsProgramIt can be determined before running, so you can add it directly. If the data may change, you should extract data from the database and add the project cyclically.

The following script determines whether the selected project can be dragged when the user starts to drag. In the department, last name, and name layers, only the data at the lowest layer can be dragged. Therefore, write the following script in the begindrag event:
Treeviewitem ltvi_source
If ltvi_source <> 2 then // you can only drag the employee
This. Drag (cancel !)
Else
// Save the dragged project and its parent project. The statement is omitted.
End if

When a user can receive and drag data on a project, the project should be highlighted to give the user some operation information. First, determine whether the project where the current mouse is located can receive the dragged data. If it can receive the data, highlight the project. Write the following script in the dragwithin event:
Treeviewitem ltvi_over
If getitem (handle, ltvi_over) =-1 then
Setdrophightlight (0)
Return 0
End if

When you release the mouse on a project that can receive and drag data, you must process the project. You usually need to delete the source data and add the data to the released target project.

[Attribute]

** Treeview attributes
▲Visible
Boolean Type, indicating whether the control is visible. The default value of this attribute is true.

▲Enabled
Boolean Type, indicating whether the control is available. The default value of this attribute is true.

▲Editlabels
Boolean Type, indicating whether the user can edit the label of the item in the control. The default value is false. Users are not allowed to edit tags.

▲Hasbuttons
Boolean Type, indicating whether the "+" and "-" buttons are displayed on the left of the Parent Project to indicate whether the project is expanded or collapsed. The default value of this attribute is true.

▲Haslines
Boolean Type, indicating whether a project is wired to a parent-child project. The default value of this attribute is true.

▲Linesatroot
Boolean indicates whether to display the lines connecting to all root projects. The default value of this attribute is false.

▲Deleteitems
Boolean Type, indicating whether you may use the delete button in the control to delete a project. The default value of this attribute is false.

▲Disabledraganddrop
Boolean indicates whether the user is prohibited from performing the drag operation. The default value of this attribute is true, and users are not allowed to perform the drag operation.

▲Hideselection
Boolean Type, indicating whether the selected content remains highlighted when the Treeview control loses focus. The default value of this attribute is true, indicating that the selected items are not highlighted when the Treeview control loses focus.

▲Tooltips
Boolean Type, indicating whether to display the tool bar bubble help. The default value of this attribute is true.

▲Checkboxes
Boolean indicates whether the check box is displayed on the left of the project. The default value is false.

▲Trackselect
Boolean indicates whether the project selects a trail, that is, when the value of this attribute is true and the cursor is over a project, the project changes color and underlines are displayed under the project, indicates that the current project is preparing to receive the mouse operation. The default value of this attribute is false.

▲Fullrowselect
Boolean Type, indicating whether the whole line is displayed when the project is selected. The default value of this attribute is false.

▲Singleexpand
Boolean Type, indicating whether only one project can be expanded. If this attribute is set to true, the selected project is expanded and the selected project is automatically collapsed. If this attribute is set to false, multiple projects can be expanded at the same time. The default value of this attribute is false.

▲Border
Boolean Type, indicating whether the control displays a border. The default value of this attribute is true. When this attribute is selected, the style displayed by the border also depends on the value of the borderstyle attribute.

▲Borderstyle
Enumeration type, indicating the display style of the border. Stylebox is available for this attribute! (Rectangular border), stylelowered! (Embedded border), styleraised! (Raised borders) and styleshadowbox! (Shadow rectangular border ).

▲Sorttype
Enumeration type. This attribute specifies the sorting rules of items in the control. Available values include ascending! (In alphabetical Ascending Order), descending! (Sort by dictionary in descending order), userdefinedsort! (Sort by the script in the SORT event) and unsorted! (Not sorted ).

▲Indent
Integer type, indicating the number of indentions of subitems in the unit of powerbuilderunit. The value of this attribute can be negative, but it is possible that the Child Project is left out of the control boundary. The default value is 0.

▲Accelerator
Integer type. The value is the ASCII code of the control shortcut chain. This property saves the ASCII code value corresponding to the control shortcut key.

** Treeviewitem attributes
▲Bold
Boolean
Text on the project tab is displayed in bold

▲Childen
Boolean
Whether the project has a sub-project. You can use this property to own a sub-project to trigger itempopulate and itemexpanding events in the future.

▲Cuthighlighted
Boolean
Determine whether the project is the object to be cut

▲Data
Any
Data value that the user wants to associate with the project

▲Drophighlighted
Boolean
Check whether the project is the object to be dragged.

▲Expanded
Boolean
Determine whether the project is expanded

▲Expandedonce
Boolean
Determine whether the project has been expanded at least once. This attribute is useful when a subitem is added to the itempopulate event of the control. It can be used to determine whether a subitem has been added.

▲Hasfocus
Boolean
Determine whether the project gets the current focus

▲Itemhandle
Long
Project handle. The handles of a project are unique, and the handles of different projects are not repeated.

▲Label
Label
Project text tag

▲Level
Integer
Determine the project level in the Treeview control. The value of the root level is 1.

▲Overlaypictureindex
Integer
Overwrite the image index number in the image list

▲Pictureindex
Integer
Index Number of the image connected to the project in the icon list

▲Selectedpictureindex
Integer
Index Number of the image associated with the project in the icon list when the project is selected

▲Selected
Boolean
Check whether the project is selected

▲Statepictureindex
Integer
Index Number of the project status chart

[Event]

◆ Begindrag
Handle
This event is triggered when you click the mouse on the control and start dragging.

◆ Beginlabeledit
Handle
This event is triggered when the text label is being edited and editing starts.

◆ Beginrightdrag
Handle
This event is triggered when you right-click the control and start dragging the control.

◆ Clicked
Handle
Triggered when a user clicks a control.

◆ Constructor
No
Triggered when the control is created. The trigger time should be before the window containing the control is opened.

◆ Deleteitem
Handle
Triggered when a project is deleted

◆ Destructor
No
Triggered when the control is deleted. The trigger time should be when the window containing the control is closed

◆ Doubleclicked
Handle
Triggered when you double-click the control.

◆ Dragdrop
Source, handle
Triggered when you drag an object to the control and release the mouse.

◆ Dragenter
Source
Triggered when you drag another object into the control.

◆ Dragleave
Source
Triggered when you drag another object out of the control.

◆ Dragwithin
Source, handle
Triggered when you move another object in the control.

◆ Endlabeledit
Handle, newtext
Triggered when the user ends the text editing of the label

◆ Getfocus
No
Triggered when the control obtains the focus. The controller is not activated when this event is triggered.

◆ Help
Xpos, ypos
Triggered when the user clicks F1 or another method to obtain help

◆ Itemcollapsed
Handle
Triggered when the project of the control is collapsed

◆ Itemcollapsing
Handle
Triggered when the project in the control is being collapsed

◆ Itemexpanded
Handle
Triggered when the control project is expanded

◆ Itemexpanding
Handle
Triggered when the control project is being expanded

◆ Itempopulate
Handle
Triggered when the project in the control is opening its Child Project

◆ Key
Key, keyflag
Triggered when a user clicks a button

◆ Losefocus
No
Triggered when the control loses focus. The Controller is still available when this event is triggered.

◆ Other
Wparm, lparm
This event is triggered when other messages are not mapped to Pb messages.

◆ Rightclicked
Handle
This event is triggered when you right-click the control.

◆ Rightdoubleclicked
Handle
This event is triggered when you right-click the control.

◆ Selectionchanged
Oldhandle, newhandle
Triggered when a project is selected

◆ Selectionchanging
Oldhandle, newhandle
Triggered before a project is selected

◆ Sort
Handle1, handle2
This event is triggered for each comparison when the control is sorted.

[Function]
★Addpicture
Add an icon or bitmap to the Treeview control. The syntax format of this function is controlname. addpicture (picturename ).

★Addstatepicture
Add a specified bitmap or icon to the status icon list of the Treeview control. The syntax of this function is controlname. addstatepicture (picturename ).

★Deleteitem
Delete the specified project and its sub-projects (if any) in the Treeview control. The function syntax is treeviewname. deleteitem (itemhandle), where itemhandle stores the only handle of the project. In many events of this control, the handle parameter is available. You can directly use it or use other functions to read the handle first.

★Deletepicture (s)
Delete the image with the specified index number in the control. The function format is controlname. deletepicture (index ). The controlname. deletepictures () function is used to delete all images in the control.

★Deletestatepicture (s)
Delete the status icon of the specified index number in the control. The function format is controlname. deletestatepicture (index ). The controlname. deletestatepictures () function is used to delete all status icons in the control.

★Editlabel
The syntax of this function is treeviewname. editlabel (itemhandle). It sets the tag of the project whose handle is itemhandle to edit.

★Expandall
The syntax of this function is treeviewname. expandall (itemhandle). It is used to expand all sub-projects under the itemhandle project. Expand all projects in the control and use this function for root-level projects.

★Expanditem
The function syntax is treeviewname. expanditem (itemhandle). It is used to expand the project whose handle is itemhandle. This function expanditem only expands the specified project, unlike expandall.

★Finditem
The syntax is treeviewname. finditem (navigationcode, itemhandle). It is used to find a project in the mode specified by navigationcode in the relative position of the itemhandle project. The navigationcode parameter is an enumerated variable. The available values are as follows.
Value inclusion
Roottreeitem! Search for the first root-level project. If no project is added to the control,-1 is returned.
Nexttreeitem! Search for the next project at the same level. If there is no next project,-1 is returned.
Previoustreeitem! Search for the previous project at the same level. If no previous project exists,-1 is returned.
Parenttreeitem! Find the handle of the parent project. If it is the root project,-1 is returned.
Childtreeitem! Find the first sub-project. If the project is collapsed, set the project to open.
-1 is returned if no sub-project exists.
Firstvisibletreeitem! Find the first visible item in the control. Note that the scroll bar is located at the top of the visible item.
Nextvisibletreeitem! Find the next expanded project. If the next expanded project is located in the visible project of the control
Previusvisibletreeitem! Search for the previous project
Currenttreeitem! Search for the selected project. -1 is returned if no selected items exist.
Drophighlighttreeitem! Search for projects with the drophightlighted attribute recently set.

You can use the values listed above to easily traverse all projects in the Treeview.

★Getitem
The function syntax is treeviewname. getitem (itemhandle, item). The function is to retrieve the data of the handle from the project specified by the itemhandle parameter to the parameter item in the treeviewitem structure.

★Insertitem
The function syntax is treeviewname. insertitem (handleparent, handleafter, label, pictureindex) is used to insert a label-based project to the control, and the insert position is under the project specified by handleparent as its sub-project, the handle is the end of the same-level project as handleafter. This function also has another syntax format: treeviewname. insertitem (handleparent, handleafter, item) is used to insert the project specified by the item variable of the treeviewitem type to the specified position of the control. The meanings of the other two parameters are exactly the same as those above.

★Insertitemfirst
Treeviewname. insertitemfirst (handleparent, label, pictureindex) or treeviewname. insertitemfirst (handleparent, item) can all be used. In the preceding syntax, the content of the inserted project label is specified by the label, and the icon is specified by the pictureindex. In the following syntax, the attributes of the inserted project can be set in more detail. The inserted position is also specified by the handleparent parameter.

★Insertitemlast
Treeviewname. insertitemlast (handleparent, label, pictureindex) or treeviewname. both the insertitemlast (handleparent, item) syntax format can insert the specified project to the project specified by the handleparent parameter and act as its last sub-project. You can insert a project attribute or set it in detail by the treeviewitem type parameter item, or specify the label and pictureindex to specify the project icon.

★Insertitemsort
Either treeviewname. insertitemsort (handleparent, label, pictureindex) or treeviewname. insertitemsort (handleparent, item) syntax format can insert a specified item to the control in a certain order. The parameter meanings are the same as those in the previous function.

★Selectitem
The function syntax treeviewname. selectitem (itemhandle) is used to select the project specified by the itemhandle handle.

★Setitem
Function Syntax: treeviewname. setitem (itemhandle, item). It uses the treeviewitem Structure Parameter item to modify the project specified by the itemhandle handle.

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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