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)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 宁武县| 辽宁省| 左云县| 府谷县| 丹寨县| 旬邑县| 柳江县| 江源县| 贵定县| 长汀县| 宽城| 昔阳县| 澄城县| 长垣县| 海口市| 格尔木市| 通河县| 古丈县| 贵港市| 皮山县| 阿城市| 垫江县| 纳雍县| 米林县| 科技| 周至县| 灌阳县| 泸溪县| 溧阳市| 巴彦县| 芷江| 内乡县| 宜城市| 松阳县| 板桥市| 定安县| 介休市| 内乡县| 辽源市| 中方县| 武胜县|