本文介绍了ComboBox文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







Im添加一些项目给Combobox赞

Hi,


Im Add Some Items To Combobox Like

Combobox cbox = new ComboBox();
cbox.Items.Add("A");
cbox.Items.Add("B");
cbox.Items.Add("C");
cbox.Items.Add("D");
cbox.Items.Add("E");









Assiging





Assiging

cbox.Text = Value From Database (Value May Be "A",or "B" or "C" or "D");



但在Combobox中文本显示我看不到值?


But In Combobox Text Display I Cannot See The Value?

推荐答案


public void bindd()
       {
           string str = "Select name,payment_id From payment";
           SqlCommand com = new SqlCommand(str, sconn);
           SqlDataAdapter sqlda = new SqlDataAdapter(com);
           DataSet ds = new DataSet();
           sqlda.Fill(ds, "payment");
           combopaymenttype.DataSource = ds.Tables["payment"].DefaultView;
           combopaymenttype.DisplayMember = "name";
           combopaymenttype.ValueMember = "payment_id";
       }



这篇关于ComboBox文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 22:23