pub struct ListView {
    pub handle: ControlHandle,
    /* private fields */
}
Expand description

A list-view control is a window that displays a collection of items. List-view controls provide several ways to arrange and display items and are much more flexible than simple ListBox.

Requires the list-view feature.

Builder parameters:

  • parent: Required. The list view parent container.
  • size: The list view size.
  • position: The list view position.
  • background_color: The list view background color in RGB format
  • double_buffer: If the list view should be double buffered (defaults to true)
  • text_color: The list view text color in RGB format
  • flags: A combination of the ListViewFlags values.
  • ex_flags: A combination of the ListViewExFlags values. Not to be confused with ex_window_flags
  • ex_window_flags: A combination of win32 window extended flags. This is the equivalent to ex_flags in the other controls
  • style: One of the value of ListViewStyle
  • item_count: Number of item to preallocate
  • list_style: The default style of the listview
  • focus: The control receive focus after being created

Control events:

  • MousePress(_): Generic mouse press events on the tree view
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: Generic mouse wheel event
  • OnKeyPress: Generic key press event
  • OnKeyRelease: Generic key release event
  • OnListViewClear: When all the items in a list view are destroyed
  • OnListViewItemRemoved: When an item is about to be removed from the list view
  • OnListViewItemInsert: When a new item is inserted in the list view
  • OnListViewItemActivated: When an item in the list view is activated by the user
  • OnListViewClick: When the user has clicked the left mouse button within the control
  • OnListViewRightClick: When the user has clicked the right mouse button within the control
  • OnListViewDoubleClick: When the user has clicked the left mouse button within the control twice rapidly
  • OnListViewColumnClick: When the user has clicked the left mouse button on ListView header column
  • OnListViewItemChanged: When an item is selected/unselected in the listview
  • OnListViewFocus: When the list view has received focus
  • OnListViewFocusLost: When the list view has lost focus

Fields

handle: ControlHandle

Implementations

Sets the image list of the listview A listview can accept different kinds of image list. See ListViewImageListType

Returns the current image list for the selected type. The returned image list will not be owned. Can return None if there is no assocaited image list

Sets the text color of the list view

Returns the current text color

Sets the background color of the list view

Returns the background color of the list view

Returns the index of the selected column. Only available if Comclt32.dll version is >= 6.0.

Sets the selected column. Only available if Comclt32.dll version is >= 6.0.

Returns the number of selected items

Inserts a column in the report. Column are only used with the Detailed list view style.

Checks if there is a column at the selected index

Returns the information of a column. Because there’s no way to fetch the actual text length, it’s up to you to set the maximum buffer size

Sets the information of a column. Does nothing if there is no column at the selected index

Deletes a column in a list view. Removing the column at index 0 is only available if ComCtl32.dll is version 6 or later.

Returns true if list view headers are visible

Enable or disable list view headers

Returns column sort indicator

Enable or disable column sort indicator. Draws a up-arrow / down-arrow.

Set the width of a column

Returns the width of a column

Select or unselect an item at row_index. Does nothing if the index is out of bounds.

Returns the index of the first selected item. If there’s more than one item selected, use selected_items

Returns the indices of every selected items.

Inserts a new item into the list view

Checks if the item at the selected row is visible

Returns true if an item exists at the selected index or false otherwise.

Returns data of an item in the list view. Returns None if there is no data at the selected index Because there is no way to fetch the actual text size, text_buffer_size must be set manually

Updates the item at the selected position Does nothing if there is no item at the selected position

Remove all items on the seleted row. Returns true if an item was removed or false otherwise. To “remove” an item without deleting the row, use update_item and set the text to “”.

Inserts multiple items into the control. Basically a loop over insert_item.

Insert multiple item at the selected row or at the end of the list if None was used. This method overrides the index and the column_index of the items. Useful when inserting strings into a single row. Ex: list.insert_items_row(None, &["Hello", "World"]);

Returns the current style of the list view

Sets the list view style of the control

Returns the number of items in the list view

Returns the number of columns in the list view

Preallocate space for n number of item in the whole control. For example calling this method with n=1000 while the list has 500 items will add space for 500 new items.

Enable or disable the redrawing of the control when a new item is added. When inserting a large number of items, it’s better to disable redraw and reenable it after the items are inserted.

Sets the spacing between icons in list-view controls that have the ICON style. dx specifies the distance, in pixels, to set between icons on the x-axis dy specifies the distance, in pixels, to set between icons on the y-axis

Invalidate the whole drawing region.

Removes all item from the listview

Returns true if the control currently has the keyboard focus

Sets the keyboard focus on the button

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

Enable or disable the control

Returns 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

Returns the size of the button in the parent window

Sets the size of the button in the parent window

Returns the position of the button in the parent window

Sets 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

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

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.