首页 > 解决方案 > 我可以使用哪些工具箱项来管理数据库列表?

问题描述

    public class Customer
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public List<Medication> Medications { get; set; }
    }

    public class Medication
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }

我可以使用什么来为每位客户添加/移除药物?我试图创建一个 CheckListBox,但我无法将选中的项目保存给客户,还有其他选项可以管理这样的列表吗?我已经创建了几种药物,但现在我想将多个药物绑定到每个客户

标签: c#winforms

解决方案


对此的众多解决方案之一是:

  • 创建拆分容器(垂直)
  • 在左侧创建 ListBox,您将在其中禁用多选
  • 在右侧创建 CheckListBox

ListBox 将Customer Name作为显示值和Customer Id值成员保存。

OnSelectedItemChange里面的事件listBox将为客户处理药物。

当您单击其他客户时,事件运行命令将首先获取List<Medication>特定Customer Id然后显示在右侧。

其他更改的处理是非常基本的。

再一次,这个问题是基于意见的,这是我的意见。


推荐阅读