Form

GPALComboBox

Everything on Settings Every Control Takes applies here too. GPAL.ComboBox builds one. WithItems fills it, taking a params array, any IEnumerable of string, or an Array, which is what an Enum.GetValues call hands back. WithSelectedIndex preselects by position and WithSelectedItem by text. At runtime SelectedValue and SelectedIndex read and write what is chosen. DisableItem greys an item that does not apply without removing it, EnableItem puts it back, IsItemEnabled answers the state and ClearItems empties the list. SelectedIndexChanged is the primary event. GPAL.ComboBoxFor(items) is the shorthand.

Examples

GPAL Fluent: High-level fluent C# API

//WithItems and WithSelectedIndex come before WithName. DisableItem leaves the item in the list, greyed and unselectable, which reads better than an item that silently disappears.

GPALComboBox browser = (GPALComboBox)GPAL.ComboBox

.WithItems("Chrome", "Edge", "Firefox")

.WithSelectedIndex(0)

.WithCallback<EventHandler>(BrowserChanged)

.WithName("browser");


// an engine this browser cannot use is greyed rather than dropped, so the reason stays visible

browser.DisableItem("Firefox");


void BrowserChanged(object sender, EventArgs e)

{

status.Text = $"Browser: {browser.SelectedValue}";

}

💬 Ask GPAL