combox 在属性设置中,DataSource为(数据集)njb1.chushai,DisplayMember 和ValueMember都设置为"nj",表chushai中的一个字段.在 InitializeComponent()中自动生成的代码为:
              this.njcombox.DataSource = this.njb1;
this.njcombox.DisplayMember = "chushai.nj";
this.njcombox.ItemHeight = 12;
this.njcombox.Location = new System.Drawing.Point(88, 16);
this.njcombox.MaxDropDownItems = 10;
this.njcombox.Name = "njcombox";
this.njcombox.Size = new System.Drawing.Size(121, 20);
this.njcombox.TabIndex = 13;
this.njcombox.ValueMember = "chushai.nj";
可一运行就是不行,单击下拉的小三角,空空的,什么也没有,我搜索了好多帖子,用它们的方法,也不行,请帮帮忙吧,多谢了!

解决方案 »

  1.   

    System.data.dataset dt=new dataset();
    sqldatapter da=new sqldatapter("查询数据库语句",myconnectonstr);
    da.fill(dt,"word");
    this.njcombox.DataSource = dt.tables["word"].defaultview;
    this.njcombox.DisplayMember ="需要查询的数据表中的字段名";
    this.njcombox.ValueMember ="需要查询的数据表中的字段名";
      

  2.   

    我用的工具箱中的数据适配器产生的数据集aaa,然后用
    comboBox1.DataSource = aaa.Tables["ydy"];
    comboBox1.DisplayMember = "hm";
    可还是不行啊
      

  3.   

    sample as follows
    http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c43c.aspx#q561q
      

  4.   

    自己解决了,缺了一句oleDbDataAdapter1.Fill(aaa1);与Kning94提供的一样,谢谢了