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();
  • 相关阅读:
    [NOIP2015] 子串 题解
    [NOIP2011] 聪明的质检员 题解
    二进制的一些概念
    [NOIP2012] 借教室 题解
    [POJ3764] The XOR Longest Path 题解
    关于本博客
    【SC-MY限定】让填写问卷星成为自动化!
    JZOJ5833 永恒
    九校联考-DL24凉心模拟Day2总结
    【简解】SP7556 Stock Charts
  • 原文地址:https://www.cnblogs.com/quke123/p/4096634.html
Copyright © 2011-2022 走看看