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 created
  • flags: A combination of the ListBoxFlags values.
  • ex_flags: A combination of win32 window extended flags. Unlike flags, ex_flags must be used straight from winapi
  • font: The font used for the listbox text
  • collection: The default collections of the listbox
  • selected_index: The default selected index in the listbox collection
  • multi_selection: The collections of indices to set as selected in a multi selection listbox

Control events:

  • OnListBoxSelect: When the current listbox selection is changed
  • OnListBoxDoubleClick: When a listbox item is clicked twice rapidly
  • MousePress(_): Generic mouse press events on the listbox
  • OnMouseMove: Generic mouse mouse event
  • OnMouseWheel: 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 the font of the control

Set the font of the control

Return true if the control currently has the keyboard focus

Set the keyboard focus on the button.

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

Return the size of the button in the parent window

Set the size of the button in the parent window

Return the position of the button in the parent window

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 base flags used during window creation

Winapi flags required by the control

Trait Implementations

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

Executes the destructor for this type. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.