Struct ListView

Source
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§

Source§

impl ListView

Source

pub fn builder() -> ListViewBuilder

Source

pub fn set_image_list( &self, list: Option<&ImageList>, list_type: ListViewImageListType, )

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

Source

pub fn image_list(&self, list_type: ListViewImageListType) -> Option<ImageList>

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

Source

pub fn set_text_color(&self, r: u8, g: u8, b: u8)

Sets the text color of the list view

Source

pub fn text_color(&self) -> [u8; 3]

Returns the current text color

Source

pub fn set_background_color(&self, r: u8, g: u8, b: u8)

Sets the background color of the list view

Source

pub fn background_color(&self) -> [u8; 3]

Returns the background color of the list view

Source

pub fn selected_column(&self) -> usize

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

Source

pub fn set_selected_column(&self, index: usize)

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

Source

pub fn selected_count(&self) -> usize

Returns the number of selected items

Source

pub fn insert_column<I: Into<InsertListViewColumn>>(&self, insert: I)

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

Source

pub fn has_column(&self, index: usize) -> bool

Checks if there is a column at the selected index

Source

pub fn column( &self, index: usize, text_buffer_size: i32, ) -> Option<ListViewColumn>

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

Source

pub fn update_column<I: Into<InsertListViewColumn>>( &self, index: usize, column: I, )

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

Source

pub fn remove_column(&self, column_index: usize)

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

Source

pub fn headers_enabled(&self) -> bool

Returns true if list view headers are visible

Source

pub fn set_headers_enabled(&self, enable: bool)

Enable or disable list view headers

Source

pub fn column_sort_arrow( &self, column_index: usize, ) -> Option<ListViewColumnSortArrow>

Returns column sort indicator

Source

pub fn set_column_sort_arrow( &self, column_index: usize, sort: Option<ListViewColumnSortArrow>, )

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

Source

pub fn set_column_width(&self, column_index: usize, width: isize)

Set the width of a column

Source

pub fn column_width(&self) -> usize

Returns the width of a column

Source

pub fn select_item(&self, row_index: usize, selected: bool)

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

Source

pub fn selected_item(&self) -> Option<usize>

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

Source

pub fn selected_items(&self) -> Vec<usize>

Returns the indices of every selected items.

Source

pub fn insert_item<I: Into<InsertListViewItem>>(&self, insert: I)

Inserts a new item into the list view

Source

pub fn item_is_visible(&self, index: usize) -> bool

Checks if the item at the selected row is visible

Source

pub fn has_item(&self, row_index: usize, column_index: usize) -> bool

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

Source

pub fn item( &self, row_index: usize, column_index: usize, text_buffer_size: usize, ) -> Option<ListViewItem>

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

Source

pub fn update_item<I: Into<InsertListViewItem>>( &self, row_index: usize, data: I, )

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

Source

pub fn remove_item(&self, row_index: usize) -> bool

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 “”.

Source

pub fn insert_items<I: Clone + Into<InsertListViewItem>>(&self, insert: &[I])

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

Source

pub fn insert_items_row<I: Clone + Into<InsertListViewItem>>( &self, row_index: Option<i32>, insert: &[I], )

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"]);

Source

pub fn list_style(&self) -> ListViewStyle

Returns the current style of the list view

Source

pub fn set_list_style(&self, style: ListViewStyle)

Sets the list view style of the control

Source

pub fn len(&self) -> usize

Returns the number of items in the list view

Source

pub fn column_len(&self) -> usize

Returns the number of columns in the list view

Source

pub fn set_item_count(&self, n: u32)

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.

Source

pub fn set_redraw(&self, enabled: bool)

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.

Source

pub fn set_icon_spacing(&self, dx: u16, dy: u16)

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

Source

pub fn invalidate(&self)

Invalidate the whole drawing region.

Source

pub fn clear(&self)

Removes all item from the listview

Source

pub fn focus(&self) -> bool

Returns true if the control currently has the keyboard focus

Source

pub fn set_focus(&self)

Sets the keyboard focus on the button

Source

pub fn enabled(&self) -> bool

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

Source

pub fn set_enabled(&self, v: bool)

Enable or disable the control

Source

pub fn visible(&self) -> bool

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))

Source

pub fn set_visible(&self, v: bool)

Show or hide the control to the user

Source

pub fn size(&self) -> (u32, u32)

Returns the size of the button in the parent window

Source

pub fn set_size(&self, x: u32, y: u32)

Sets the size of the button in the parent window

Source

pub fn position(&self) -> (i32, i32)

Returns the position of the button in the parent window

Source

pub fn set_position(&self, x: i32, y: i32)

Sets the position of the button in the parent window

Source

pub fn class_name(&self) -> &'static str

Winapi class name used during control creation

Source

pub fn flags(&self) -> u32

Winapi base flags used during window creation

Source

pub fn forced_flags(&self) -> u32

Winapi flags required by the control

Trait Implementations§

Source§

impl Default for ListView

Source§

fn default() -> ListView

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

impl Drop for ListView

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&ListView> for ControlHandle

Source§

fn from(control: &ListView) -> Self

Converts to this type from the input type.
Source§

impl From<&mut ListView> for ControlHandle

Source§

fn from(control: &mut ListView) -> Self

Converts to this type from the input type.
Source§

impl PartialEq<ControlHandle> for ListView

Source§

fn eq(&self, other: &ControlHandle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<ListView> for ControlHandle

Source§

fn eq(&self, other: &ListView) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.