zoukankan      html  css  js  c++  java
  • combox填充

    //前台绑定kcb_state
    private void addItems()
    {
       DataSet ds = new DataSet();
       ds = this.sc.getItems(code,describe,tableName,strCondition);
       this.kcb_state.DataSource = ds.Tables[0];
       this.kcb_state.DisplayMember = "describe";  //设置显示值
       this.kcb_state.ValueMember = "code";    // 实际值    
    }
    //获取(getItems)
    public static DataSet getItems(string code,string describe,string tableName,string strCondition)
    {
        string sql = "select distinct "+code+" as code ,"+describe+" as describe  from "+tableName+" where 1=1 "+strCondition;
        DB.DataHelper dtHelper = new DB.DataHelper();
            return dtHelper.ExecuteSql(sql);  
    } 
    
    
    Dictionary<int,string> dic = new Dictionary<int,string>();
    dic.Add(1,"a");
    dic.Add(2,"b");
    foreach(var keyValue in dic)
    {
    this.combox.items.add(keyValue)
    }
     
    // 需要使用时
    int index = ((Dictionary<int,string>)this.combox.SelectedItem).Key;
    string text = ((Dictionary<int,string>)this.combox.SelectedItem).Value;
    
    
    
    private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
         this. ComboBox1.Items.AddRange(new object[] {"体制与管理","实验教学","仪器设备","实验队伍","环境与安全","管理规章制度"});
    }
    
    
    
    private void fuZhi()
            {
                DataSet ds = new DataSet();
                ds = this.sc.GetItemsDescribe("ZT01");
                this.kcb_state.DataSource = ds.Tables[0];
                this.kcb_state.DisplayMember = "describe";  //设置显示值
                this.kcb_state.ValueMember = "code_class";    // 实际值    
            }

    //获取值得时候:
    string state = "";
    if(this.kcb_state.SelectedValue != null)
      state = this.kcb_state.SelectedValue.ToString().Trim();
  • 相关阅读:
    自动化测试工具Gauge--contexts 与 Tear Down steps
    Redis官网第一次闲逛
    针对 《Linux就该这么学》 之 “第三章---管道符、重定向、环境变量” 摘抄、操练及拓展
    父shell 和 子shell; shell脚本的几种执行方式
    麒麟操作系统操练Linux基操
    HTTP代理
    gcc/g++ 安全编码
    golang 生成rsa秘钥对
    depth of feild
    Emission pass
  • 原文地址:https://www.cnblogs.com/quke123/p/4096634.html
Copyright © 2011-2022 走看看