标签c#listBox DisplayMember [英] c# listBox DisplayMember

查看:440
本文介绍了标签c#listBox DisplayMember的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c#WinForms.Listbox.

c# WinForms.Listbox.

listBox1.DataSource = ds.Tables[0].DefaultView;
listBox1.DisplayMember = "Question";
listBox1.ValueMember = "idQuestion";

//for ValueMember showing...   
textBox2.Text = listBox1.SelectedValue.ToString();

//What I must use for DisplayMember showing?  
textbox3.Text = ??????????

推荐答案

使用无类型表可能不那么容易.组合框具有用于列表框的Text属性:

That may not be so easy with untyped tables. A Combobox has a Text property, for the listbox:

 textbox3.Text = listBox1.SelectedItem;

为您提供项目",但这可能是DataRowView.您可以投放它:
((DataRowViw) SelectedItem).Row[3]

Gets you the 'item' but that probably is a DataRowView. You can cast it :
((DataRowViw) SelectedItem).Row[3]

这篇关于标签c#listBox DisplayMember的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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