Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I got a 2D array (loaded from a csv) that I have displayed into a listbox but I need the button I made to be able to move the food items and update the 2d array so the user can see the updated list in the list box - How do I go on about this?

What I have tried:

Array is as follows:
Apple,Free,Orange,Free
Pear,Free,Free,Free
Walnut,Edamame,Free,Free

Basically, the "Free" are the spots where user can move the food then if the slot is already taken, the system will throw an error saying "Invalid Move"
Posted
Updated 21-Apr-18 21:09pm
Comments
Patrice T 22-Apr-18 2:03am    
And you have some code to fix ?
BillWoodruff 22-Apr-18 4:53am    
You need to add much more detail to your question.

The ListBox 'MultiColumn property set to 'true only does vertical scrolling adjustment: it is NOT what you need here.

Use a ListView, and BIND the ListView to a 2d array: when you change the array values, the ListView will change.

Do you have one array with two dimensions, or two arrays ?

When you click the Button what determines what list item is moved to what position ?

1 solution

You could try using drag and drop functionality, see example here:
Drag and Drop between list boxes - Beginner's Tutorial[^]

But a ListView is probably more suitable for your purposes, see example here: c# - How to drag & drop items in the same ListView? - Stack Overflow[^]
 
Share this answer
 
v2
Comments
BillWoodruff 22-Apr-18 4:58am    
My vote of #3. At least it occurred to you a ListView should be used; after you came back from writing science-fiction.
RickZeeland 22-Apr-18 9:40am    
May I offer you a tulip as a token of peace: https://1drv.ms/u/s!AqqLYm_bbW5uuV4aao5dfxg_tQzZ
BillWoodruff 23-Apr-18 4:13am    
This is not about you, and me: it's about technical quality.
RickZeeland 23-Apr-18 4:18am    
Ah, that's a relief, I was wondering if it was something personal maybe :)

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