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();
            }
  • 相关阅读:
    linux [Fedora] 下的 "飞秋/飞鸽传书"
    弹跳是不是自由落体?
    插件的简单原理
    WebService的简单应用
    普通按钮的另一种提交方式(调用后台事件)
    ASPNET服务端控件练习(一个机试题)
    AJAX简单的数据增删改与分页应用
    new XMLHttpRequest()和页面关系
    c++中placement new
    netty的引用计数
  • 原文地址:https://www.cnblogs.com/kenter/p/1996804.html
Copyright © 2011-2022 走看看