Skip to content

ComboBox

Tyberious edited this page Sep 4, 2023 · 1 revision

ComboBox Control

The ComboBox class is a part of the SimpleConsole.Controls library, designed to create a combo box control for console-based user interfaces. It allows users to select an option from a dropdown list.

Properties

  • X and Y: Set the position of the checkbox.
  • BackgroundColor and ForegroundColor: Customize colors for the checkbox.
  • Items: Gets or sets the list of items to be displayed in the dropdown menu.
  • SelectedIndex: Gets or sets the index of the selected item
  • MaxLength: Gets or sets the maximum length of the combobox
  • SelectedText: Gets or sets the text of the currently selected item in the ComboBox.

Methods

  • ShowList(): Displays the list of items in the combobox and handles user input for selecting an item
  • SetFocus(): Sets focus on the ComboBox, allowing the user to interact with it. If Enter is pressed and the ComboBox is not already expanded, it displays the dropdown list.

Example

ComboBox comboBox = new ComboBox();
comboBox.X = 5;
comboBox.Y = 5;
comboBox.Items = new List<string> { "Option 1", "Option 2", "Option 3" };
comboBox.SetFocus();
Clone this wiki locally