internal GUIListBoxItem AddListBoxItem(string name, string text) { GUIListBoxItem lbi = new GUIListBoxItem(Game, name, text); lbi.Initialize(); components.Add(lbi); return(lbi); }
public void SetItem(string itemname) { GUIListBoxItem Item = null; foreach (GUIListBoxItem lbi in Items) { if (lbi.Name == itemname) { Item = lbi; continue; } } if (Item != null) { SelectItem(Item, null); } }
/// <summary> /// Ensures that only one value is selected at a time /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void SelectItem(GUIComponent sender, OnMouseClickEventArgs args) { GUIListBoxItem listBox = (GUIListBoxItem)sender; if (selectedItem == "") { // If nothing is currently selected, select. listBox.SelectItem(true); selectedItem = listBox.Name; currentItem.Text = listBox.Text; OCList(this, null); } else if (selectedItem == listBox.Name) { // If this item is already selected, deselect it. //listBox.SelectItem(false); //selectedItem = ""; //currentItem.Text = "Select Item ..."; } else { // If there's something else selected, remove it, then add the new one foreach (GUIListBoxItem lbi in Items) { if (lbi.Name == selectedItem) { lbi.SelectItem(false); } } listBox.SelectItem(true); selectedItem = listBox.Name; currentItem.Text = listBox.Text; OCList(this, null); } }