* UIComboTreeView: 修复CanSelectRootNode时可以展开子节点

This commit is contained in:
Sunny 2022-07-12 16:45:37 +08:00
parent 3d3b28e446
commit 0120148ffe
4 changed files with 28 additions and 9 deletions

View File

@ -143,10 +143,13 @@ namespace Sunny.UI
{ {
if (!treeView.CheckBoxes) if (!treeView.CheckBoxes)
{ {
if (e.Node.Nodes.Count == 0 || CanSelectRootNode) if (e.Location.X > treeView.DrawLeft(e.Node))
{ {
DoValueChanged(this, e.Node); if (e.Node.Nodes.Count == 0 || CanSelectRootNode)
Close(); {
DoValueChanged(this, e.Node);
Close();
}
} }
} }
} }

View File

@ -48,9 +48,6 @@ namespace Sunny.UI
this.ButtonClick += UIComboDataGridView_ButtonClick; this.ButtonClick += UIComboDataGridView_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
DropDownWidth = 500;
DropDownHeight = 300;
} }
public event OnComboDataGridViewFilterChanged FilterChanged; public event OnComboDataGridViewFilterChanged FilterChanged;
@ -89,6 +86,8 @@ namespace Sunny.UI
InitializeComponent(); InitializeComponent();
fullControlSelect = true; fullControlSelect = true;
CreateInstance(); CreateInstance();
DropDownWidth = 500;
DropDownHeight = 300;
} }
/// <summary> /// <summary>

View File

@ -20,6 +20,7 @@
* 2021-11-11: V3.0.0 * 2021-11-11: V3.0.0
* 2022-05-15: V3.0.8 CheckBoxes时自己选中节点文字可切换状态 * 2022-05-15: V3.0.8 CheckBoxes时自己选中节点文字可切换状态
* 2022-06-16: V3.2.0 * 2022-06-16: V3.2.0
* 2022-07-12: V3.2.1 CanSelectRootNode时可以展开子节点
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -40,6 +41,8 @@ namespace Sunny.UI
InitializeComponent(); InitializeComponent();
fullControlSelect = true; fullControlSelect = true;
CreateInstance(); CreateInstance();
DropDownWidth = 250;
DropDownHeight = 220;
} }
private void InitializeComponent() private void InitializeComponent()
@ -54,9 +57,6 @@ namespace Sunny.UI
this.ButtonClick += this.UIComboTreeView_ButtonClick; this.ButtonClick += this.UIComboTreeView_ButtonClick;
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
DropDownWidth = 250;
DropDownHeight = 220;
} }
[DefaultValue(250)] [DefaultValue(250)]

View File

@ -87,6 +87,12 @@ namespace Sunny.UI
view.AfterLabelEdit += View_AfterLabelEdit; view.AfterLabelEdit += View_AfterLabelEdit;
} }
internal int DrawLeft(TreeNode node)
{
if (view == null || node == null) return 0;
return view.DrawLeft(node);
}
public void SetNodePainter(TreeNode node, Color backColor, Color foreColor) public void SetNodePainter(TreeNode node, Color backColor, Color foreColor)
{ {
if (view.IsNull()) return; if (view.IsNull()) return;
@ -880,6 +886,17 @@ namespace Sunny.UI
} }
} }
public int DrawLeft(TreeNode node)
{
int drawLeft;
if (!HBar.Visible)
drawLeft = (node.Level + 1) * Indent + 3;
else
drawLeft = -(int)(Width * HBar.Value * 1.0 / HBar.Maximum) + (node.Level + 1) * Indent + 3;
return drawLeft;
}
protected override void OnDrawNode(DrawTreeNodeEventArgs e) protected override void OnDrawNode(DrawTreeNodeEventArgs e)
{ {
base.OnDrawNode(e); base.OnDrawNode(e);