c# - CheckedListBox 中的第二级

标签 c# .net

我在创建 CheckedListBox 的“第二级”时遇到一些问题。

示例:

这是我的 CheckedListBox:

enter image description here

代码:

 checkedListBox_materiałyDoRozliczenia.DataSource = dataTableMaterials;
 checkedListBox_materiałyDoRozliczenia.DisplayMember = "material";

为此,我将 dataTable 绑定(bind)为 checkListBox 的数据源。

我想要完成的事情是这样的:

enter image description here

如您所见,有“第二级”。 当检查元素时,我希望出现这个“第二级”。此“第二级”的数据源将是另一个数据表。

你能帮我完成这个任务吗?

有可能做到吗?

最佳答案

您正在寻找的东西称为“TreeView”。
TreeView 如下所示:
enter image description here

您只想向子项( TreeView 中的项目)添加复选框。
有一篇很棒的documentation为此,或 asp.net youtube video .

Codeproject 还有一个 interactive demo其中包括源代码。

关于c# - CheckedListBox 中的第二级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39894079/

相关文章:

c# - 仅当使用 System.Data.OracleClient 时,函数才保持 INVALID,通过 SQL Developer 工作

c# - OnPaint 在调整大小时留下痕迹

c# - 在哪里可以找到所有可用 ChromeOption 参数的列表?

c# - 如何阻止 RichTextBox Inline 在 TextChanged 中被删除?

c# - 当文件名中不存在文件扩展名时从文件中检索文件扩展名(在 C# 中)?

c# - 在 ASP.NET 中使用文件 uploader 将图像上传到 Azure Blob?

c# - 在 .Net 中使用大于 2 个字节的 unicode 字符

c# - 使用C#发送短信

c# - 使用 Linq 只返回每个项目一次

c# - 独立于 DBMS 的查询