将列表框文本传递到文本框 [英] passing listbox text to textbox
本文介绍了将列表框文本传递到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有用于将列表框项目文本传递到文本框的代码,但是我得到了System.data.DataRowView而不是那些项目文本的文本\
Hello
I have this code for passing listbox items text to textbox but I get System.data.DataRowView instead of the text of those text of items\
foreach (var item in listPattern1.Items)
{
txtPattern.Text += "," + item.ToString() + ",";
}
我不知道如何获取这些项目的文本.
I dont know how to get text of those items
推荐答案
这是一个简单的解决方案,您曾经在列表框中选择要在文本框中显示的代码,所以代码是
This is simple solution what ever selected in listbox you want to show it in a textbox the code is
string selectedvalues=string.Empty;
foreach(ListItem li in lstbox.Items)
if(li.Selected)
selectedvalues+=li.Text+", ";
txtSelected.Text=selectedvalues(0,selectedvalues.LastIndexOf(","));
很简单:)
Simple :)
因为我很愚蠢,很愚蠢,很抱歉要求我已经在这里解决了,但是我之间并没有什么区别,所以我很抱歉提出这个要求同样的事情
非常愚蠢,还是谢谢大家
Because I am stupid, and stupid and I am sorry for asking that I already got solved here some time ago, but I had little differences, and I am truly sorry for asking the same thing
very stupid of me, thanks anyway everybody
这篇关于将列表框文本传递到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文