组合框在运行时不起作用 [英] Combo box is not working at runtime
本文介绍了组合框在运行时不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
Hello All,
推荐答案
  ; 您必须使用this.comboBox3.DataSource = ds.Tables [0] .DefaultView;以下是总代码...
You had to use this.comboBox3.DataSource = ds.Tables[0].DefaultView; Here is the total code...
string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=CurrencyDetails;userid=sa;password=C0llecti0n;Pooling=False";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string sqlStr = "select CurrencyType from tblCurrency;";
SqlDataAdapter adapter = new SqlDataAdapter(sqlStr, con);
DataSet ds = new DataSet();
adapter.TableMappings.Add("Table", "tblCurrency");
adapter.Fill(ds);
this.comboBox3.DataSource = ds.Tables[0].DefaultView;
this.comboBox3.DisplayMember = "CurrencyType";
this.comboBox3.ValueMember = "CurrencyType";
con.Close();
adapter.Dispose();
这篇关于组合框在运行时不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文