从列表框中选择值并将其显示在标签上 [英] select the values from list box and display it on label

查看:151
本文介绍了从列表框中选择值并将其显示在标签上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i希望从列表框中显示多个所选项目以进行标记。



所以我应该遵循哪个循环,意味着如何我可以做吗。从列表框中显示多个选定项目到标签。

解决方案

  var  sb =  new  StringBuilder(); 
foreach object item in YourListBox.SelectedItems)
sb.AppendFormat( {0}< br />,item.DisplayPropertyOfYourChoice);
yourLabelCtl.Text = sb.ToString();


Label1.Text = string.Empty;

foreach( ListBox2.Items中的ListItem li)

{

if(li.Selected)

{

Label1.Text + = li.Text +
;

}



}

dis是它。 ..

hi,
i want to display multiple selected items from list box to label.

so which loop i should follow, means how can i do it. to get displayed multiple selected items from list box to label.

解决方案

var sb = new StringBuilder();
foreach( object item in YourListBox.SelectedItems )
   sb.AppendFormat("{0}<br />", item.DisplayPropertyOfYourChoice);
yourLabelCtl.Text = sb.ToString();


Label1.Text = string.Empty;
foreach (ListItem li in ListBox2.Items)
{
if (li.Selected)
{
Label1.Text += li.Text + "
";
}

}
dis is it...


这篇关于从列表框中选择值并将其显示在标签上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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