Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

C#
var sb = new StringBuilder();
foreach( object item in YourListBox.SelectedItems )
   sb.AppendFormat("{0}<br />", item.DisplayPropertyOfYourChoice);
yourLabelCtl.Text = sb.ToString();
 
Share this answer
 
Comments
Member 9671810 3-Jan-13 10:33am    
can you give some simple one. plz
i am a beginner so.....
fjdiewornncalwe 3-Jan-13 10:53am    
Did you look at my answer. It's about as simple as it gets.
Label1.Text = string.Empty;
foreach (ListItem li in ListBox2.Items)
{
if (li.Selected)
{
Label1.Text += li.Text + "
";
}

}
dis is it...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900