C# ComboBox 抓取與設定
C# ComboBox 抓取與設定
01.建立選單內容
System.Object[] ItemObject = new System.Object[24]; this.ComboBox元件.DropDownStyle = ComboBoxStyle.DropDownList;//設定只能為選取模式 this.ComboBox元件.Items.AddRange(ItemObject);//新增清單 this.ComboBox元件.SelectedIndex = -1;//0
02.清空選單內容:
this.ComboBox元件.Items.Clear();//清空所有內容
03.取得選擇內容:
int selectedIndex = this.ComboBox元件.SelectedIndex;//抓取選擇的index Object selectedItem = this.ComboBox元件.SelectedItem; String StrData = this.ComboBox元件.SelectedItem.ToString();