当前位置: 首页 > news >正文

Node Checking - Checkboxes and Radio Buttons 节点检查 - 复选框和单选按钮

Goto Nodes 节点

Node Checking - Checkboxes and Radio Buttons 节点检查 - 复选框和单选按钮

要选择节点,请使用节点检查功能,该功能为树级别启用内置复选框或单选按钮。在绑定模式下,您可以将节点检查状态与数据库字段同步。本文档详细介绍了此主题。

在这里插入图片描述

Enable Checkboxes/Radio Buttons 启用复选框/单选按钮

显示所有节点的复选框/单选按钮

将 TreeListOptionsView.CheckBoxStyle 属性设置为 Check 或 Radio。

在这里插入图片描述

treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Check;
//or
treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Radio;

TreeListOptionsView.CheckBoxStyle 属性指定所有 TreeList 节点的默认复选框显示模式。您可以覆盖根节点和任何节点的子节点的此设置,如下所示。

仅显示根节点的复选框/单选按钮

将 TreeListOptionsView.RootCheckBoxStyle 属性设置为 Check 或 Radio。将 TreeListOptionsView.CheckBoxStyle 属性设置为 Default。

在这里插入图片描述

treeList1.OptionsView.RootCheckBoxStyle = NodeCheckBoxStyle.Check;
treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Default;
//or
treeList1.OptionsView.RootCheckBoxStyle = NodeCheckBoxStyle.Radio;
treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Default;

显示除根节点之外的所有节点的复选框/单选按钮

将 TreeListOptionsView.CheckBoxStyle 设置为 Check/Radio,并将 TreeListOptionsView.RootCheckBoxStyle 设置为 None。

在这里插入图片描述

treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Check;
treeList1.OptionsView.RootCheckBoxStyle = NodeCheckBoxStyle.None;
//or
treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Radio;
treeList1.OptionsView.RootCheckBoxStyle = NodeCheckBoxStyle.None;

显示/隐藏特定节点的子节点的复选框/单选按钮

使用节点的 TreeListNode.ChildrenCheckBoxStyle 属性。此属性将覆盖指定节点的子节点的 TreeListOptionsView.CheckBoxStyle 设置。

在这里插入图片描述

treeList1.OptionsView.CheckBoxStyle = DefaultNodeCheckBoxStyle.Check;
treeList1.OptionsView.RootCheckBoxStyle = NodeCheckBoxStyle.None;
TreeListNode node1 = treeList1.FindNodeByFieldValue("DEPARTMENT", "Sales and Marketing");
node1.ChildrenCheckBoxStyle = DevExpress.XtraTreeList.NodeCheckBoxStyle.Radio;

Related API 相关 API

  • TreeListOptionsView.CheckBoxStyle - 获取或设置所有 TreeList 节点是否应显示复选框、单选按钮,或者两者都不显示。

  • TreeListOptionsView.RootCheckBoxStyle - 获取或设置根 TreeList 节点是应绘制复选框、单选按钮,还是两者都不绘制。

  • TreeListNode.ChildrenCheckBoxStyle - 获取或设置此节点拥有的所有子节点是否应显示复选框和单选按钮,或者两者都不显示。

Indeterminate Check State 不确定检查状态

常规复选框允许最终用户在 Checked 和 Unchecked 状态之间切换。如果启用 TreeListOptionsBehavior.AllowIndeterminateCheckState 属性,则 TreeList 节点将支持三种检查状态(Unchecked、Indeterminate 和 Checked)。按顺序单击复选框可在这些状态之间切换。

Related API 相关 API

  • TreeListOptionsBehavior.AllowIndeterminateCheckState - 获取或设置最终用户是否可以通过单击鼠标将节点切换到不确定检查状态。

Get Nodes with Checked/Unchecked/Indeterminate States 获取具有 Checked/Unchecked/Indeterminate 状态的节点

要检索所有选中的节点,请使用 TreeList.GetAllCheckedNodes 方法。

以下代码演示如何使用 TreeList.GetAllCheckedNodes 方法检索选中的节点,并修改其值。

List<TreeListNode> list = treeList1.GetAllCheckedNodes();
foreach (TreeListNode node in list) {decimal budget = Convert.ToDecimal(node["BUDGET"])*1.1m;node["BUDGET"] = budget;
}

您可以使用节点迭代器以递归方式检索与特定条件匹配的节点(例如,未选中的节点或具有不确定状态的节点)。

以下示例说明如何使用节点迭代器检索未选中的 TreeList 节点。

using DevExpress.XtraTreeList.Nodes.Operations;GetUncheckedNodesOperation op = new GetUncheckedNodesOperation();
treeList1.NodesIterator.DoOperation(op);
//Get the number of unchecked nodes:
int count = op.TargetNodes.Count;//The operation class that collects unchecked nodes
class GetUncheckedNodesOperation : TreeListOperation {public List<TreeListNode> TargetNodes = new List<TreeListNode>();public GetUncheckedNodesOperation() : base() { }public override void Execute(TreeListNode node) {if (node.CheckState == CheckState.Unchecked)TargetNodes.Add(node);}
}

Obtain and Set Node Check States. Recursive Checking. 获取并设置节点检查状态。递归检查。

使用以下成员在代码中指定节点检查状态。

  • TreeListNode.Checked - 允许您在启用两种检查状态(Checked 和 Unchecked)时获取/设置节点的检查状态

  • TreeListNode.CheckState - 允许您在启用三种检查状态(Checked、Indeterminate 和 Unchecked)时获取/设置节点的检查状态

  • TreeList.SetNodeCheckState - 允许您以递归和非递归方式设置节点的检查状态。

  • TreeList.CheckAll, TreeListNode.CheckAll, TreeList.UncheckAll, TreeListNode.UncheckAll - 允许您检查和取消选中属于此 TreeListControl 或特定父节点的所有节点的方法。

Recursive Checking 递归检查

要在最终用户切换父节点的检查状态时检查/取消选中子节点(反之亦然),请使用 TreeListOptionsBehavior.AllowRecursiveNodeChecking 属性。

Example 例

TreeListNode node1 = treeList1.FindNodeByFieldValue("DEPARTMENT", "Sales and Marketing");
if (node1 != null)treeList1.SetNodeCheckState(node1, CheckState.Checked, false);

Sync Check States with Data Source 将检查状态与数据源同步

使用 TreeList.CheckBoxFieldName 属性将节点检查状态与特定数据源字段同步。

如果 TreeList 节点仅支持 checked 和 unchecked 状态,则 bound 数据源字段应为 Boolean 类型。如果 TreeList 节点使用三种检查状态,则数据源字段应为 Nullable Boolean 类型。

Perform Custom Actions on Node Checking 对节点检查执行自定义操作

处理 TreeList.BeforeCheckNode 和 TreeList.AfterCheckNode 事件。

Custom Paint Check Boxes 自定义绘制复选框

您可以通过处理 TreeList.CustomDrawNodeCheckBox 事件来自定义绘制复选框。

Printing/Export 打印/导出

要打印/导出复选框,请启用 TreeListOptionsPrint.PrintCheckBoxes 选项。


http://www.mrgr.cn/news/56311.html

相关文章:

  • ubuntu重启后显示不出图形界面
  • 安卓流式布局实现记录
  • 15分钟学Go 第2天:安装Go环境
  • 后台管理员登录实现--系统篇
  • 尚硅谷大数据Flink1.17实战教程-笔记04【Flink DataStream API】
  • Mysql数据库 | 第三章 | insert | update | delete | select | 统计函数 | 分组统计
  • 重生之“我打数据结构,真的假的?”--1.顺序表(无习题)
  • 常见软件生命周期类型
  • QSpinBox、QDoubleSpinBox
  • ArcGIS002:软件自定义设置
  • 在Debian上安装向日葵
  • 目前机器学习算法优化在实际应用中有哪些成功案例?
  • 程序设计基础I-单元测试4(机测+编程题)
  • SpringBoot02:第一个springboot程序
  • 【K8S系列】Kubernetes Pod节点Pending状态及解决方案详解【已解决】
  • 极氪MIX主打一个“够大、够好玩”,期待值拉满~
  • 医院信息化与智能化系统(5)
  • 网址工具大全
  • 浏览器调起摄像头
  • docker安装mysql
  • 【多商户商城】
  • 乙武洋匡取得成功,成为著名作家。他的生命反射给我们:正面、积极、乐观的思考态度是多么重要啊!
  • Python学习的自我理解和想法(19)
  • Excel重新踩坑3:条件格式;基本公式运算符;公式中的单元格引用方式;公式菜单栏其他有用的功能说明;
  • Leetcode—1279. 红绿灯路口【简单】Plus(多线程)
  • 2024/10/22 408计组大题