Struct native_windows_gui::ListView [−][src]
pub struct ListView { pub handle: ControlHandle, // some fields omitted }
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 formatdouble_buffer
: If the list view should be double buffered (defaults to true)text_color
: The list view text color in RGB formatflags
: A combination of the ListViewFlags values.ex_flags
: A combination of the ListViewExFlags values. Not to be confused withex_window_flags
ex_window_flags
: A combination of win32 window extended flags. This is the equivalent toex_flags
in the other controlsstyle
: One of the value ofListViewStyle
item_count
: Number of item to preallocatelist_style
: The default style of the listviewfocus
: The control receive focus after being created
Control events:
MousePress(_)
: Generic mouse press events on the tree viewOnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel eventOnKeyPress
: Generic key press eventOnKeyRelease
: Generic key release eventOnListViewClear
: When all the items in a list view are destroyedOnListViewItemRemoved
: When an item is about to be removed from the list viewOnListViewItemInsert
: When a new item is inserted in the list viewOnListViewItemActivated
: When an item in the list view is activated by the userOnListViewClick
: When the user has clicked the left mouse button within the controlOnListViewRightClick
: When the user has clicked the right mouse button within the controlOnListViewDoubleClick
: When the user has clicked the left mouse button within the control twice rapidlyOnListViewColumnClick
: When the user has clicked the left mouse button on ListView header columnOnListViewItemChanged
: When an item is selected/unselected in the listviewOnListViewFocus
: When the list view has received focusOnListViewFocusLost
: 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
pub fn set_column_sort_arrow(
&self,
column_index: usize,
sort: Option<ListViewColumnSortArrow>
)
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.
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
.
pub fn insert_items_row<I: Clone + Into<InsertListViewItem>>(
&self,
row_index: Option<i32>,
insert: &[I]
)
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"]);
Returns the current style of the list view
Sets the list view style of the control
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.
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
Sets the position of the button in the parent window
Winapi class name used during control creation
Winapi flags required by the control
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for ListView
impl !UnwindSafe for ListView