如何通过按钮更新2D阵列? [英] How do I update a 2D array via button?

查看:79
本文介绍了如何通过按钮更新2D阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个2D数组(从csv加载)我已经显示到列表框中但是我需要我做的按钮能够移动食物项并更新2d数组,以便用户可以看到更新的列表列表框 - 我如何继续这个?



我尝试过:



数组如下:

苹果,免费,橙色,免费

梨,免费,免费,

核桃,毛豆,免费,免费



基本上,免费是用户可以移动食物的地方,如果已经采取了插槽,系统将抛出一个错误说无效移动

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"

推荐答案

您可以尝试使用拖放功能,请参见此处的示例:

在列表框之间拖放 - 初学者教程 [ ^ ]



ListView 可能更适合您的目的,请参见此处的示例: c# - 如何拖拽删除同一ListView中的项目? - 堆栈溢出 [ ^ ]
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[^]


这篇关于如何通过按钮更新2D阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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