示例#1
0
 /// <summary>
 /// 设置下拉列表选中指定的值
 /// </summary>
 /// <param name="combo">下拉列表</param>
 /// <param name="value">指定的CListItem中的值</param>
 public static void SetComboBoxItem(this ComboBox combo, string value)
 {
     for (int i = 0; i < combo.Items.Count; i++)
     {
         CListItem item = combo.Items[i] as CListItem;
         if (item != null && item.Value == value)
         {
             combo.SelectedIndex = i;
         }
     }
 }
示例#2
0
        /// <summary>
        /// 获取下拉列表的值
        /// </summary>
        /// <param name="combo">下拉列表</param>
        /// <returns></returns>
        public static string GetComboBoxValue(this ComboBox combo)
        {
            CListItem item = combo.SelectedItem as CListItem;

            if (item != null)
            {
                return(item.Value);
            }
            else
            {
                return("");
            }
        }