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();
            }
  • 相关阅读:
    QTabWidget改变tabBar位置 并改变文字方向
    QScrollArea-QWidget 添加滚动条
    QPushbutton
    QFileDialog
    MFC RadioButton分组用法
    MFC 调用模态对话框和非模态对话框
    3D Active Button Magic 使用备忘
    unhandledRejection 处理方法
    .Net Core和DevOps系列:Jenkins安装(Docker)
    .Net Core和DevOps系列:Gitea安装(Docker)
  • 原文地址:https://www.cnblogs.com/kenter/p/1996804.html
Copyright © 2011-2022 走看看