Struct winsafe::gui::spec::ListBoxItems
source · pub struct ListBoxItems<'a> { /* private fields */ }
gui
only.Expand description
Exposes item methods of a ListBox
control.
You cannot directly instantiate this object, it is created internally by the control.
Implementations§
source§impl<'a> ListBoxItems<'a>
impl<'a> ListBoxItems<'a>
sourcepub fn add(&self, items: &[impl AsRef<str>])
pub fn add(&self, items: &[impl AsRef<str>])
Adds new texts by sending lb::AddString
messages.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListBox; // initialized somewhere
my_list.items().add(&["John", "Mary"]);
sourcepub fn count(&self) -> u32
pub fn count(&self) -> u32
Retrieves the number of items by sending an
lb::GetCount
message.
sourcepub fn delete(&self, index: u32)
pub fn delete(&self, index: u32)
Deletes the item at the given index by sending an
lb::DeleteString
message.
sourcepub fn delete_all(&self)
pub fn delete_all(&self)
Deletes all items by sending an
lb::ResetContent
message.
sourcepub fn ensure_visible(&self, index: u32)
pub fn ensure_visible(&self, index: u32)
Ensures that the specified item in a list box is visible by sending an
lb::SetTopIndex
message.
sourcepub fn iter(&self) -> impl Iterator<Item = String> + 'a
pub fn iter(&self) -> impl Iterator<Item = String> + 'a
Returns an iterator over the texts.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListBox; // initialized somewhere
for text in my_list.items().iter() {
println!("Text {}", text);
}
sourcepub fn iter_selected(&self) -> impl Iterator<Item = (u32, String)> + 'a
pub fn iter_selected(&self) -> impl Iterator<Item = (u32, String)> + 'a
Returns an iterator over the currently selected texts.
This method works for both single and multiple-selection lists.
§Examples
use winsafe::{self as w, prelude::*, gui};
let my_list: gui::ListBox; // initialized somewhere
for (sel_idx, text) in my_list.items().iter_selected() {
println!("Text {}: {}", sel_idx, text);
}
sourcepub fn selected_count(&self) -> u32
pub fn selected_count(&self) -> u32
Retrieves the number of selected items by sending an
lb::GetSelCount
message.
sourcepub fn text(&self, index: u32) -> String
pub fn text(&self, index: u32) -> String
Retrieves the text at the given position, if any, by sending a
lb::GetText
message.