* UIComboTreeView: 修复使用清空按钮后,再次打开下拉框,上次的选择内容还是存在

This commit is contained in:
Sunny 2023-06-12 20:55:49 +08:00
parent 681be2cfd3
commit 0fcb485817
4 changed files with 34 additions and 19 deletions

View File

@ -1,5 +1,4 @@
using System.ComponentModel;
using System.Windows.Forms;
namespace Sunny.UI
{
@ -207,23 +206,10 @@ namespace Sunny.UI
private void uiCheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
foreach (TreeNode node in treeView.Nodes)
{
CheckAllChildNodes(node, uiCheckBox1.Checked);
}
}
public void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
{
treeNode.Checked = nodeChecked;
foreach (TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if (node.Nodes.Count > 0)
{
CheckAllChildNodes(node, nodeChecked);
}
}
if (uiCheckBox1.Checked)
treeView.CheckedAll();
else
treeView.UnCheckedAll();
}
}
}

View File

@ -566,7 +566,6 @@ namespace Sunny.UI
DropDown?.Invoke(this, e);
if (fullControlSelect || MouseLocation.X > Width - 30)
{
ButtonClick?.Invoke(this, e);

View File

@ -24,6 +24,7 @@
* 2022-11-30: V3.3.0 Clear方法
* 2023-02-04: V3.3.1
* 2023-04-02: V3.3.4
* 2023-06-12: V3.3.8 使
******************************************************************************/
using System;
@ -229,6 +230,7 @@ namespace Sunny.UI
NeedDrawClearButton = false;
Text = "";
TreeView.SelectedNode = null;
TreeView.UnCheckedAll();
Invalidate();
return;
}

View File

@ -94,6 +94,16 @@ namespace Sunny.UI
view.MouseClick += View_MouseClick;
}
public void CheckedAll()
{
view.CheckedAll();
}
public void UnCheckedAll()
{
view.UnCheckedAll();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
@ -1341,6 +1351,24 @@ namespace Sunny.UI
}
}
}
public void CheckedAll()
{
foreach (TreeNode node in Nodes)
{
node.Checked = true;
SetChildNodeCheckedState(node, true);
}
}
public void UnCheckedAll()
{
foreach (TreeNode node in Nodes)
{
node.Checked = false;
SetChildNodeCheckedState(node, false);
}
}
}
}
}