1

我在组合框中使用多列。所以,我想在stock_typestock_type_dscription之间放置一个空格。我尝试了以下编码,但组合框中的所有项目都替换为system.data.datarowview

 string sqlstk = "SELECT stock_type, stock_type_desc FROM stktype";
 SqlCommand stkcom = new SqlCommand(sqlstk, myconnection);

 SqlDataAdapter dastk = new SqlDataAdapter(stkcom);
 DataSet1 dsstk = new DataSet1();
 dastk.Fill(dsstk, "StockType");

 cboStk.DisplayMember = "stock_type" + " " +"stock_type_des";
 cboStk.ValueMember = "stock_type" + " " + "stock_type_des";
 cboStk.DataSource = dsstk.Tables["StockType"];

任何人都知道将允许空间放入多列组合框的方法,请帮助和指导。提前致谢

4

1 回答 1

3

我会改变sql语句如下

 string sqlstk = "SELECT stock_type + ' ' +stock_type_des as combined FROM stktype";

进而

 cboStk.DisplayMember = "combined";
 cboStk.ValueMember = "combined";
于 2013-11-01T06:24:53.107 回答