Struct native_windows_gui::ListBox
[−]
[src]
pub struct ListBox<D: Clone + Display> { /* fields omitted */ }
A listbox control
Methods
impl<D: Clone + Display> ListBox<D>
[src]
fn len(&self) -> usize
Return the number of items in the inner collection
fn collection(&self) -> &Vec<D>
Return the inner collection of the listbox
fn collection_mut(&mut self) -> &mut Vec<D>
Return the inner collection of the listbox, mutable.
If the inner listbox is changed, listbox.sync
must be called to show the changes in the listbox
fn sync(&self)
Reload the content of the listbox
fn push(&mut self, item: D)
Add an item at the end of the listbox. Updates both the inner collection and the ui.
fn remove(&mut self, index: usize) -> D
Remove an item from the inner collection and the listbox. Return the removed item.
Panics
if index is out of bounds.
fn insert(&mut self, index: usize, item: D)
Insert an item at the selected position in the lisbox and the inner collection.
If index is -1, the item is added at the end of the list.
fn get_selected_index(&self) -> Option<usize>
Return the index of currently selected item.
Return None if there is no selected item
If the listbox can have more than one selected item, use get_selected_indexes
fn get_selected_indexes(&self) -> Vec<usize>
Return a vector filled with the selected indexes of the listbox. If nothing is selected or the listbox do not support multiple selection, the returned vector will be empty.
fn index_selected(&self, index: usize) -> bool
Return true if index
is currently selected in the listbox
fn set_selected_index(&self, index: usize)
Set the selected index in a single choice listbox.
For multi-select listbox use set_index_selected
or set_range_selected
If index
is usize::max_value
, remove the selected index from the listbox
fn set_index_selected(&self, index: usize, selected: bool)
Set the selected state of the item located at index. Only work for multi-select listbox
For single listbox, use set_selected_index
If index is usize::max_value
, the change is applied to every item.
fn set_range_selected(&self, index_min: usize, index_max: usize, selected: bool)
Select or unselect a range of index in the list box. The range is inclusive. Only work if the listbox can have multiple items selected.
For single listbox, use set_selected_index
fn len_selected(&self) -> usize
Return the number of selected items.
fn clear(&mut self)
Remove every item in the inner collection and in the listbox
fn find_string<'a>(&self, text: &'a str, full_match: bool) -> Option<usize>
Try to find an item with the text text
in the collection. If one is found, return its index else, returns None.
If full_match
is true, the text must match exactly otherwise it only needs to match the beginning.
The search is NOT case sensitive.
fn get_string(&self, index: usize) -> Option<String>
Return the item text at the provided index. Returns None if the index is not valid.
fn get_readonly(&self) -> bool
Return true if the listbox is currently in a readonly mode, false otherwise.
fn set_readonly(&self, readonly: bool)
Set or unset the listbox readonly flag
fn get_multi_select(&self) -> bool
Return true if the listbox accepts multiple selected items, false otherwise.
fn set_multi_select(&self, multi: bool)
Set or unset the listbox multiple selected flag
fn get_visibility(&self) -> bool
fn set_visibility(&self, visible: bool)
fn get_position(&self) -> (i32, i32)
fn set_position(&self, x: i32, y: i32)
fn get_size(&self) -> (u32, u32)
fn set_size(&self, w: u32, h: u32)
fn get_enabled(&self) -> bool
fn set_enabled(&self, e: bool)
Trait Implementations
impl<D: Clone + Display> Control for ListBox<D>
[src]
fn handle(&self) -> AnyHandle
Should return the underlying handle to the object
fn control_type(&self) -> ControlType
Should return the type of the control. For custom controls, the return value should be Undefined
(the default).
fn free(&mut self)
If specified, should free any ressource allocated in the template build
function. This includes functions like DestroyWindow
.