zoukankan      html  css  js  c++  java
  • 带Key,Value实现的Combobox

    struct itemEx
            {
                
    public object Value;
                
    public string Text;
                
    public itemEx(object value, string text)
                {
                    
    this.Value = value;
                    
    this.Text = text;
                }
                
    //重点是override ToString 
                public override string ToString()
                { 
    return Text; }
            }
    ComboBoxItemCollection coll = comboBoxEdit1.Properties.Items;
                coll.BeginUpdate();
                
    try
                {
                    coll.Add(
    new itemEx("Sven""Petersen"));
                    coll.Add(
    new itemEx("Cheryl""Saylor"));
                    coll.Add(
    new itemEx("Dirk""Luchte"));
                }
                
    finally
                {
                    coll.EndUpdate();
                    comboBoxEdit1.SelectedIndex 
    = -1;
                }
    private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
            {
                itemEx item 
    = new itemEx();
                item 
    = (itemEx)(this.comboBoxEdit1.SelectedItem);
                
    string strValue = item.Value.ToString().Trim();
            }
  • 相关阅读:
    getSupportFragmentManager要用在FragmentActivity及其子类中
    nginx 配置php
    openwrt 安装 ser2net 配置
    stm32 hid 键盘描述
    外部中断实验
    stm32 UART串口
    stm32 按键
    小结-stm32 驱动LED灯
    ASCII 计算机码
    debian/ubuntu安装桌面环境
  • 原文地址:https://www.cnblogs.com/kenter/p/1996804.html
Copyright © 2011-2022 走看看