user2901955
user2901955

Reputation: 103

Multicolumn Combo box

I am using multi column in combo box. So, I would like to put a space between the stock_type and stock_type_dscription. I tried the below coding but all the items in combo box replaced with 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"];

Anyone do know the way to allowed space put in multicolumn combo box, please help and guide. Thanks in advance

Upvotes: 1

Views: 198

Answers (1)

Damith
Damith

Reputation: 63105

I would change the sql statement as below

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

and then

 cboStk.DisplayMember = "combined";
 cboStk.ValueMember = "combined";

Upvotes: 3

Related Questions