Struct native_windows_gui::ListBox [−][src]
pub struct ListBox<D: Display + Default> { pub handle: ControlHandle, // some fields omitted }
Expand description
A list box is a control window that contains a simple list of items from which the user can choose.
Requires the list-box
feature.
Builder parameters:
parent
: Required. The listbox parent container.size
: The listbox size.position
: The listbox position.enabled
: If the listbox can be used by the user. It also has a grayed out look if disabled.focus
: The control receive focus after being createdflags
: A combination of the ListBoxFlags values.ex_flags
: A combination of win32 window extended flags. Unlikeflags
, ex_flags must be used straight from winapifont
: The font used for the listbox textcollection
: The default collections of the listboxselected_index
: The default selected index in the listbox collectionmulti_selection
: The collections of indices to set as selected in a multi selection listbox
Control events:
OnListBoxSelect
: When the current listbox selection is changedOnListBoxDoubleClick
: When a listbox item is clicked twice rapidlyMousePress(_)
: Generic mouse press events on the listboxOnMouseMove
: Generic mouse mouse eventOnMouseWheel
: Generic mouse wheel event
use native_windows_gui as nwg; fn build_listbox(listb: &mut nwg::ListBox<&'static str>, window: &nwg::Window, font: &nwg::Font) { nwg::ListBox::builder() .flags(nwg::ListBoxFlags::VISIBLE | nwg::ListBoxFlags::MULTI_SELECT) .collection(vec!["Hello", "World", "!!!!"]) .multi_selection(vec![0, 1, 2]) .font(Some(font)) .parent(window) .build(listb); }
Fields
handle: ControlHandle
Implementations
Add a new item to the listbox. Sort the collection if the listbox is sorted.
Insert an item in the collection and the control.
SPECIAL behaviour! If index is std::usize::MAX
, the item is added at the end of the collection.
The method will still panic if index > len
with every other values.
Remove the item at the selected index and returns it. Panic of the index is out of bounds
Return the index of the currencty selected item for single value list box.
Return None
if no item is selected.
Return the number of selected item in the list box Returns 0 for single select list box
Return a list index Returns an empty vector for single select list box.
Return the display value of the currenctly selected item for single value
Return None
if no item is selected. This reads the visual value.
Set the currently selected item in the list box for single value list box. Does nothing if the index is out of bound If the value is None, remove the selected value
Select the item as index index
in a multi item list box
Unselect the item as index index
in a multi item list box
Unselect every item in the list box
Select every item in the list box
Select a range of items in a multi list box
Unselect a range of items in a multi list box
Search an item that begins by the value and select the first one found. The search is not case sensitive, so this string can contain any combination of uppercase and lowercase letters. Return the index of the selected string or None if the search was not successful
Check if the item at index
is selected by the user
Return false
if the index is out of range.
Update the visual of the control with the inner collection. This rebuild every item in the list box and can take some time on big collections.
Set the item collection of the list box. Return the old collection
Clears the control and free the underlying collection. Same as set_collection(Vec::new())
Return the number of items in the control. NOT the inner rust collection
Return true if the control user can interact with the control, return false otherwise
Enable or disable the control
Return 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
Set the position of the button in the parent window
Get read-only access to the inner collection of the list box This call refcell.borrow under the hood. Be sure to drop the value before calling other list box methods
Get mutable access to the inner collection of the list box. Does not update the visual
control. Call sync
to update the view. This call refcell.borrow_mut under the hood.
Be sure to drop the value before calling other list box methods
Winapi class name used during control creation
Winapi flags required by the control
Trait Implementations
Auto Trait Implementations
impl<D> !RefUnwindSafe for ListBox<D>
impl<D> UnwindSafe for ListBox<D> where
D: UnwindSafe,