pub struct TreeView {
    pub handle: ControlHandle,
}
Expand description

A tree-view control is a window that displays a hierarchical list of items.

While a treeview can support selected multiple item programatically (using select_item), this is not fully supported by the winapi implementation.

Requires the tree-view feature

Builder parameters:

  • parent: Required. The tree-view parent container.
  • position: The treeview position.
  • enabled: If the treeview can be used by the user. It also has a grayed out look if disabled.
  • focus: The control receive focus after being created
  • flags: A combination of the TreeViewFlags values.
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • font: The font used for the treeview text
  • parent: The treeview parent container.
  • image_list: Image list containing the icon to use in the tree-view

Control events:

  • MousePress(_): Generic mouse press events on the tree view
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
  • OnTreeViewClick: When the user has clicked the left mouse button within the control.
  • OnTreeViewDoubleClick: When the user has clicked the left mouse button within the control twice rapidly.
  • OnTreeViewRightClick: When the user has clicked the right mouse button within the control.
  • OnTreeFocusLost: When the control has lost the input focus
  • OnTreeFocus: When the control has acquired the input focus
  • OnTreeItemDelete: Just before an item is deleted. Also sent for all the children.
  • OnTreeItemExpanded: After an item was expanded or collapsed. Sends a EventData::OnTreeItemUpdate.
  • OnTreeItemChanged: After the state of an item was changed. Sends a EventData::OnTreeItemUpdate.
  • OnTreeItemSelectionChanged: After the current selection was changed. Sends a EventData::OnTreeItemChanged.

Fields

handle: ControlHandle

Implementations

Sets the image list of the treeview

Returns the image list of the treeview or None if there is none. The returned image list is not owned

Sets the image that will appear left to the item text. index is the index of the image in the image-list Won’t do anything if the control do not have a image list or if the item is not in the tree If on_select is set to true, sets the icon that is used when an item is active

Returns the index of the image in the tree view image list. If there is no image list in the control or the item is not in the control, 0 will be returned. If on_select is set to true, returns the icon that is used when an item is active

Sets the text color in the treeview

Returns the text color in the treeview

Retrieves the amount, in pixels, that child items are indented relative to their parent items.

Sets the width of indentation for a tree-view control and redraws the control to reflect the new width.

Return the root item of the tree view if one is present. If there is no root in the tree, returns None.

Returns the first child of an item or None if the item has no child or if it’s not part of the tree view To iterate over all the children, use TreeView.iter_item(&parent_item)

Returns the next sibling in the tree or None if the item has no more sibling or if it’s not part of the tree view

Returns the previous sibling in the tree or None if the item has no more sibling or if it’s not part of the tree view

Returns the parent of the item in the tree or None if the item is root

Return the currently selected item. If there are more than one selected item, returns the first one. If there is no selected item, returns None.

Returns the selected items in a Treeview If there is no selected items, returns an empty Vec.

Returns the number of selected item in the tree view

Insert a new item into the TreeView and return a reference to new newly added item

Insert a new item into the TreeView with associated lParam and return a reference to new newly added item

Remove an item and its children from the tree view

Selects the specified tree-view item and scrolls the item into view.

Unselects an item from the treeview

Creates an iterator over the tree view items

Creates an iterator over the children of an item. This does not include the item itself.

Returns the text of the selected item. Return None if the item is not in the tree view. The returned text value cannot be bigger than 260 characters

Set the text for specified item in the treeview.

Returns the lParam of the selected item. Return None if the item is not in the tree view.

Returns true if the tree view item has children. Returns None if the item is not in the tree view.

Returns the item state in the tree view or None if the item is not in the tree view

Expands or collapses the list of child items associated with the specified parent item, if any.

Ensures that a tree-view item is visible, expanding the parent item or scrolling the tree-view control, if necessary.

Remove every item from the treeview by removing the root item

Return the total number of item in the tree view

Return the number of item in the tree view visible by the user

Invalidate the whole drawing region.

Return the font of the control

Set the font of the control

Return true if the control currently has the keyboard focus

Set the keyboard focus on the button.

Return true if the control user can interact with the control, return false otherwise

Enable or disable the control

Return true if the control is visible to the user. Will return true even if the control is outside of the parent client view (ex: at the position (10000, 10000))

Show or hide the control to the user

Return the size of the button in the parent window

Set the size of the button in the parent window

Return the position of the button in the parent window

Set the position of the button in the parent window

Winapi class name used during control creation

Winapi base flags used during window creation

Winapi flags required by the control

Begins to in-place edit the specified item’s text. Return None if Failed. Return the treeview’s handle if successful.

End the in-place editing of the tree item’s label. The parameter f_cancel indicates whether the editing is canceled without being saved to the label. If this parameter is TRUE, the system cancels editing without saving the changes. Otherwise, the system saves the changes to the label. Return true if successful, otherwise return false.

Trait Implementations

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.