I have a listbox control, and i want to select all the elements present in the listbox and to store them in a list collection. I need this because my reqirement is to send all the elements to another class.
pls help me..
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal GilbileRank #268 · 9.4K reputationPosted Apr 8, 2013, 1:02 AM EDT
you could try the following.
List
for(int i=0;i
lst.Add(listbox1.Items[i].Text);
}
Hope that solves your problem.
With Regards,
Vishal Gilbile
santosh parida34 reputationPosted Apr 8, 2013, 1:23 AM EDT
Vishal GilbileRank #268 · 9.4K reputationPosted Apr 8, 2013, 1:31 AM EDT
Once you got the list you can send it in multiple ways.For eg:- You could create a constructor in your second class which accepts a List
I think that solves your problem.
With Regards,
Vishal Gilbile.
santosh parida34 reputationPosted Apr 8, 2013, 1:34 AM EDT
Vishal GilbileRank #268 · 9.4K reputationPosted Apr 8, 2013, 1:44 AM EDT
Kindly mark the answer as accepted if it had helped you.
With Regard,
Vishal Gilbile