Struct native_windows_gui::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 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
sourceimpl ListView
impl ListView
pub fn builder() -> ListViewBuilder
sourcepub fn set_image_list(
&self,
list: Option<&ImageList>,
list_type: ListViewImageListType
)
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
sourcepub fn image_list(&self, list_type: ListViewImageListType) -> Option<ImageList>
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
sourcepub fn set_text_color(&self, r: u8, g: u8, b: u8)
pub fn set_text_color(&self, r: u8, g: u8, b: u8)
Sets the text color of the list view
sourcepub fn text_color(&self) -> [u8; 3]
pub fn text_color(&self) -> [u8; 3]
Returns the current text color
sourcepub fn set_background_color(&self, r: u8, g: u8, b: u8)
pub fn set_background_color(&self, r: u8, g: u8, b: u8)
Sets the background color of the list view
sourcepub fn background_color(&self) -> [u8; 3]
pub fn background_color(&self) -> [u8; 3]
Returns the background color of the list view
sourcepub fn selected_column(&self) -> usize
pub fn selected_column(&self) -> usize
Returns the index of the selected column. Only available if Comclt32.dll version is >= 6.0.
sourcepub fn set_selected_column(&self, index: usize)
pub fn set_selected_column(&self, index: usize)
Sets the selected column. Only available if Comclt32.dll version is >= 6.0.
sourcepub fn selected_count(&self) -> usize
pub fn selected_count(&self) -> usize
Returns the number of selected items
sourcepub fn insert_column<I: Into<InsertListViewColumn>>(&self, insert: I)
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.
sourcepub fn has_column(&self, index: usize) -> bool
pub fn has_column(&self, index: usize) -> bool
Checks if there is a column at the selected index
sourcepub fn column(
&self,
index: usize,
text_buffer_size: i32
) -> Option<ListViewColumn>
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
sourcepub fn update_column<I: Into<InsertListViewColumn>>(
&self,
index: usize,
column: I
)
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
sourcepub fn remove_column(&self, column_index: usize)
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.
sourcepub fn headers_enabled(&self) -> bool
pub fn headers_enabled(&self) -> bool
Returns true if list view headers are visible
sourcepub fn set_headers_enabled(&self, enable: bool)
pub fn set_headers_enabled(&self, enable: bool)
Enable or disable list view headers
sourcepub fn column_sort_arrow(
&self,
column_index: usize
) -> Option<ListViewColumnSortArrow>
pub fn column_sort_arrow(
&self,
column_index: usize
) -> Option<ListViewColumnSortArrow>
Returns column sort indicator
sourcepub 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.
sourcepub fn set_column_width(&self, column_index: usize, width: isize)
pub fn set_column_width(&self, column_index: usize, width: isize)
Set the width of a column
sourcepub fn column_width(&self) -> usize
pub fn column_width(&self) -> usize
Returns the width of a column
sourcepub fn select_item(&self, row_index: usize, selected: bool)
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.
sourcepub fn selected_item(&self) -> Option<usize>
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
sourcepub fn selected_items(&self) -> Vec<usize>
pub fn selected_items(&self) -> Vec<usize>
Returns the indices of every selected items.
sourcepub fn insert_item<I: Into<InsertListViewItem>>(&self, insert: I)
pub fn insert_item<I: Into<InsertListViewItem>>(&self, insert: I)
Inserts a new item into the list view
sourcepub fn item_is_visible(&self, index: usize) -> bool
pub fn item_is_visible(&self, index: usize) -> bool
Checks if the item at the selected row is visible
sourcepub fn has_item(&self, row_index: usize, column_index: usize) -> bool
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.
sourcepub fn item(
&self,
row_index: usize,
column_index: usize,
text_buffer_size: usize
) -> Option<ListViewItem>
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
sourcepub fn update_item<I: Into<InsertListViewItem>>(&self, row_index: usize, data: I)
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
sourcepub fn remove_item(&self, row_index: usize) -> bool
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 “”.
sourcepub fn insert_items<I: Clone + Into<InsertListViewItem>>(&self, insert: &[I])
pub fn insert_items<I: Clone + Into<InsertListViewItem>>(&self, insert: &[I])
Inserts multiple items into the control. Basically a loop over insert_item
.
sourcepub 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"]);
sourcepub fn list_style(&self) -> ListViewStyle
pub fn list_style(&self) -> ListViewStyle
Returns the current style of the list view
sourcepub fn set_list_style(&self, style: ListViewStyle)
pub fn set_list_style(&self, style: ListViewStyle)
Sets the list view style of the control
sourcepub fn column_len(&self) -> usize
pub fn column_len(&self) -> usize
Returns the number of columns in the list view
sourcepub fn set_item_count(&self, n: u32)
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.
sourcepub fn set_redraw(&self, enabled: bool)
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.
sourcepub fn set_icon_spacing(&self, dx: u16, dy: u16)
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
sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Invalidate the whole drawing region.
sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Returns true if the control user can interact with the control, return false otherwise
sourcepub fn set_enabled(&self, v: bool)
pub fn set_enabled(&self, v: bool)
Enable or disable the control
sourcepub fn visible(&self) -> bool
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))
sourcepub fn set_visible(&self, v: bool)
pub fn set_visible(&self, v: bool)
Show or hide the control to the user
sourcepub fn set_position(&self, x: i32, y: i32)
pub fn set_position(&self, x: i32, y: i32)
Sets the position of the button in the parent window
sourcepub fn class_name(&self) -> &'static str
pub fn class_name(&self) -> &'static str
Winapi class name used during control creation
sourcepub fn forced_flags(&self) -> u32
pub fn forced_flags(&self) -> u32
Winapi flags required by the control
Trait Implementations
sourceimpl From<&ListView> for ControlHandle
impl From<&ListView> for ControlHandle
sourceimpl From<&mut ListView> for ControlHandle
impl From<&mut ListView> for ControlHandle
sourceimpl PartialEq<ControlHandle> for ListView
impl PartialEq<ControlHandle> for ListView
sourcefn eq(&self, other: &ControlHandle) -> bool
fn eq(&self, other: &ControlHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ListView
impl !Send for ListView
impl !Sync for ListView
impl Unpin for ListView
impl !UnwindSafe for ListView
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more