[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

WINDOWS FORM LISTBOX HELP

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 9
Thread images: 4

File: listbox.gif (13KB, 504x388px) Image search: [Google]
listbox.gif
13KB, 504x388px
I'm making a program where I have to compare any 2 selected objects from a ListBox. This is what I'm trying to do:

object figure1 = lstFiguras.SelectedItem;
object figure2 = lstFiguras.SelectedItem;

What I want to happen is that the user highlights 2 seleccions from the ListBox. I want figure1 to be assigned the first selection, and figure2 to be assigned the second seleccion, but I can't seem to find a property or workaround that lets this happen. One ListBox only lets me use one SelectedItem. Is there a workaround of sorts I can use?

Image not related, aside from being a listbox.
>>
Might help if you told us what language you were working with.
>>
>>291652
Of course, sorry, it's C#. Only language I've used. I assumed a Windows Form would have the same code for any language.
>>
File: 1.jpg (48KB, 934x515px) Image search: [Google]
1.jpg
48KB, 934x515px
>>291656
>One ListBox only lets me use one SelectedItem.
Have you tried this?

If you have, then you could try using somekind of Do{} While()
>>
>>291680
Sorry, I didn't explain myself very well.

I already have it set so that multiple items can be selected from the ListBox. The problem is, after I highlight 2 different items, I want them assigned to different variables.

In your picture, for example, after selecting 1 and 4, I want 1 to be assigned to VariableOne, and the 4 to be assigned to VariableTwo.
>>
File: 2.jpg (80KB, 1018x705px) Image search: [Google]
2.jpg
80KB, 1018x705px
>>291656
>>291680
The code should be something like this.
>>
File: 3.jpg (17KB, 556x256px) Image search: [Google]
3.jpg
17KB, 556x256px
>>291686
Well you can follow this code:
>>291687
just add an array to save the values of the selected items in the listbox. Something like this.
>>
>>291690
And of course, add an exception to avoid the user to select more than 2 items from the listbox.
>>
>>291690
Well, butter my backside and call me a biscuit, this did it. I've got an exam in 7 hours and you may have just saved the day. Thanks very much, anon. (And to the other anon, too!)
Thread posts: 9
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.