Gridview组合框显示值成员而不是显示成员。 [英] Gridview combo box is displaying value member instead of display member.

查看:87
本文介绍了Gridview组合框显示值成员而不是显示成员。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个带有文本框和组合框的网格视图。

我已经从数据集中绑定了组合框值但是我可以看到网格中的值成员,当我在列表中选择组合框时,我可以看到显示成员。

如何让显示成员看到。

这是示例代码

 ds.Tables [  GGPI].Columns.Add(  doseqty); 
ds.Tables [ GGPI]。Columns.Add( doseid);
ds.Tables [ GGPI]。Columns.Add( timesqty);
ds.Tables [ GGPI]。Columns.Add( timesid);



 doseid.DataSource = Stock.GetDoseList(); 
doseid.DataPropertyName = Doseid;
doseid.DisplayMember = DoseDesc;
doseid.ValueMember = DoseId;

解决方案

你好,

试用这个样例代码





DataTable dt = new DataTable();



dt.Columns.Add(doseDesc);

dt.Columns。添加(doseid);

dt.Columns.Add(timesqty);

dt.Columns.Add(timesid);



dt.Rows.Add(new object [] {aaa,id1,q1,4});

dt.Rows。添加(新对象[] {bbb,id2,q2,44});





DataGridViewTextBoxColumn txtCol = new DataGridViewTextBoxColumn();

DataGridViewComboBoxColumn comboCol = new DataGridViewComboBoxColumn();

comboCol.DataSource = dt;

comboCol.DisplayMember =doseDesc ;

comboCol.ValueMember =doseid;



dataGridView1.Columns.Add(txtCol);

dataGridView1.Columns.Add(comboCol);

Hello,

I have an gridview with text box and combobox.
I have binded the combo box values from dataset but i can see value member in grid ,when i select the combo box in the list i can see display member.
How can i make display member to see.
Here is the sample code

ds.Tables["GGPI"].Columns.Add("doseqty");
           ds.Tables["GGPI"].Columns.Add("doseid");
           ds.Tables["GGPI"].Columns.Add("timesqty");
           ds.Tables["GGPI"].Columns.Add("timesid");


doseid.DataSource = Stock.GetDoseList();
           doseid.DataPropertyName = "Doseid";
           doseid.DisplayMember = "DoseDesc";
           doseid.ValueMember = "DoseId";

解决方案

Hello,
Try this out sample code


DataTable dt = new DataTable();

dt.Columns.Add("doseDesc");
dt.Columns.Add("doseid");
dt.Columns.Add("timesqty");
dt.Columns.Add("timesid");

dt.Rows.Add(new object[]{"aaa","id1","q1",4});
dt.Rows.Add(new object[] {"bbb", "id2", "q2", 44 });


DataGridViewTextBoxColumn txtCol = new DataGridViewTextBoxColumn();
DataGridViewComboBoxColumn comboCol = new DataGridViewComboBoxColumn();
comboCol.DataSource = dt;
comboCol.DisplayMember = "doseDesc";
comboCol.ValueMember = "doseid";

dataGridView1.Columns.Add(txtCol);
dataGridView1.Columns.Add(comboCol);


这篇关于Gridview组合框显示值成员而不是显示成员。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆