Loading...

          java .net

          ComboBox 手動綁定數據項


          ===========ValueObject.cs============

          using System;
          using System.Collections.Generic;
          using System.Text;

          namespace psms.util
          {
              class ValueObject
              {
                  private string value;
                  private string text;

                  public ValueObject(string v, string t)
                  {
                      this.value = v;
                      this.text = t;
                  }

                  public string Value
                  {
                      get { return this.value;}
                  }
                  public string Text
                  {
                      get { return this.text; }
                  }

              }
          }

          ===============綁定數據===============

          this.combIn_Acc.Items.Add(new util.ValueObject("", ""));
          this.combIn_Acc.Items.Add(new util.ValueObject("0","未做帳"));
          this.combIn_Acc.Items.Add(new util.ValueObject("1", "已做帳"));
                     
          this.combIn_Acc.ValueMember = "value";
          this.combIn_Acc.DisplayMember = "text";
          this.combIn_Acc.SelectedIndex = 0;


          ================取值==================


          if (this.combIn_Acc.SelectedIndex >= 0)
          {
             if (((util.ValueObject)this.combIn_Acc.SelectedItem).Value.ToString() != "")
             {
                 condition.Append(" and in_acc = ").Append(((util.ValueObject)this.combIn_Acc.SelectedItem).Value.ToString()).Append(" ");
             }
          }


          不知道為什么this.combIn_Acc.SelectedValue總是報空指針異常,想不明白,換了上面的取值方法終于可行了

          posted on 2008-08-26 22:06 閱讀(925) 評論(2)  編輯  收藏

          評論

          # re: ComboBox 手動綁定數據項 2012-05-31 22:46 xz

          高手 好貼。有時候不從數據庫 幾個字段。手動添加。這樣不錯  回復  更多評論   

          # re: ComboBox 手動綁定數據項 2012-05-31 22:47 xz

          不錯貼子 有時候 手動添加幾條數據 不要從數據庫取   回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 武山县| 洛南县| 桂林市| 霸州市| 宣汉县| 和田市| 栾川县| 进贤县| 吉首市| 呼图壁县| 河北区| 咸丰县| 瑞金市| 新丰县| 蓬莱市| 鄱阳县| 榆树市| 鄂尔多斯市| 临高县| 沂南县| 卢龙县| 通江县| 偃师市| 牙克石市| 澄江县| 淳安县| 卢龙县| 湘潭市| 尚志市| 道孚县| 定兴县| 开封县| 黎平县| 马公市| 乌兰察布市| 梅州市| 垫江县| 玉门市| 偏关县| 清徐县| 辽宁省|