* UIEditForm: 代码生成增加ComboTreeView类型
This commit is contained in:
parent
0a0a71e0da
commit
de6fa5a9ba
Binary file not shown.
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI.Demo
|
||||
{
|
||||
@ -54,6 +55,16 @@ namespace Sunny.UI.Demo
|
||||
|
||||
string[] sex = new[] { "男", "女" };
|
||||
|
||||
TreeNode[] nodes = new TreeNode[3];
|
||||
nodes[0] = new TreeNode("AA");
|
||||
nodes[1] = new TreeNode("BB");
|
||||
nodes[2] = new TreeNode("CC");
|
||||
nodes[0].Nodes.Add("AA11");
|
||||
nodes[0].Nodes.Add("AA22");
|
||||
nodes[0].Nodes.Add("AA33");
|
||||
nodes[1].Nodes.Add("BB11");
|
||||
nodes[1].Nodes.Add("BB22");
|
||||
|
||||
UIEditOption option = new UIEditOption();
|
||||
option.AutoLabelWidth = true;
|
||||
option.Text = "增加";
|
||||
@ -63,6 +74,7 @@ namespace Sunny.UI.Demo
|
||||
option.AddCombobox("Sex", "性别", sex, 1, true, true);
|
||||
option.AddCombobox("Info", "关联", infoList, "Name", "Id", "2");
|
||||
option.AddSwitch("Switch", "选择", false, "打开", "关闭");
|
||||
option.AddComboTreeView("ComboTree", "选择", nodes, nodes[1].Nodes[1]);
|
||||
|
||||
UIEditForm frm = new UIEditForm(option);
|
||||
frm.CheckedData += Frm_CheckedData;
|
||||
@ -76,6 +88,7 @@ namespace Sunny.UI.Demo
|
||||
Console.WriteLine("性别: " + sex[(int)frm["Sex"]]);
|
||||
Console.WriteLine("关联: " + frm["Info"]);
|
||||
Console.WriteLine("选择: " + frm["Switch"]);
|
||||
Console.WriteLine("选择: " + frm["ComboTree"]);
|
||||
}
|
||||
|
||||
frm.Dispose();
|
||||
|
@ -209,7 +209,7 @@ namespace Sunny.UI
|
||||
|
||||
SizeF sf = g.MeasureString(Text, Font);
|
||||
|
||||
if (Direction == LineDirection.Horizontal && Height > sf.Height)
|
||||
if (Direction == LineDirection.Horizontal)
|
||||
{
|
||||
switch (TextAlign)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
* 2020-01-01: V2.2.0 增加文件说明
|
||||
* 2021-04-26: V3.0.3 代码生成增加Switch类型,代码生成增加Combobox类型
|
||||
* 2021-05-19: V3.0.3 动态生成表单,增加校验方法
|
||||
* 2021-10-26: V3.0.8 代码生成增加ComboTreeView类型
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -222,6 +223,25 @@ namespace Sunny.UI
|
||||
edit.SelectedValue = info.Value;
|
||||
}
|
||||
|
||||
ctrls.Add(edit);
|
||||
}
|
||||
|
||||
if (info.EditType== EditType.ComboTreeView)
|
||||
{
|
||||
UIComboTreeView edit = new UIComboTreeView();
|
||||
edit.CanSelectRootNode = true;
|
||||
edit.ShowLines = true;
|
||||
edit.DropDownStyle = UIDropDownStyle.DropDownList;
|
||||
edit.Left = option.LabelWidth;
|
||||
edit.Width = info.HalfWidth ? option.ValueWidth / 2 : option.ValueWidth;
|
||||
edit.Top = top;
|
||||
edit.Parent = this;
|
||||
edit.Name = "Edit_" + info.DataPropertyName;
|
||||
edit.Enabled = info.Enabled;
|
||||
|
||||
edit.TreeView.Nodes.Clear();
|
||||
edit.TreeView.Nodes.AddRange((TreeNode[])info.DataSource);
|
||||
edit.TreeView.SelectedNode = (TreeNode)info.Value;
|
||||
|
||||
ctrls.Add(edit);
|
||||
}
|
||||
@ -399,6 +419,13 @@ namespace Sunny.UI
|
||||
if (edit == null) continue;
|
||||
info.Value = edit.Active;
|
||||
}
|
||||
|
||||
if (info.EditType == EditType.ComboTreeView)
|
||||
{
|
||||
UIComboTreeView edit = this.GetControl<UIComboTreeView>("Edit_" + info.DataPropertyName);
|
||||
if (edit == null) continue;
|
||||
info.Value = edit.TreeView.SelectedNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -36,7 +37,9 @@ namespace Sunny.UI
|
||||
DateTime,
|
||||
Password,
|
||||
Combobox,
|
||||
Switch
|
||||
Switch,
|
||||
ComboTreeView
|
||||
|
||||
}
|
||||
|
||||
public class EditInfo
|
||||
@ -269,5 +272,25 @@ namespace Sunny.UI
|
||||
Infos.Add(info);
|
||||
Dictionary.TryAdd(info.DataPropertyName, info);
|
||||
}
|
||||
|
||||
public void AddComboTreeView(string dataPropertyName, string text, TreeNode[] nodes, TreeNode value, bool enabled = true, bool halfWidth = false)
|
||||
{
|
||||
if (Dictionary.ContainsKey(dataPropertyName))
|
||||
throw new DuplicateNameException(dataPropertyName + ": 已经存在");
|
||||
|
||||
EditInfo info = new EditInfo()
|
||||
{
|
||||
DataPropertyName = dataPropertyName,
|
||||
EditType = EditType.ComboTreeView,
|
||||
Text = text,
|
||||
Value = value,
|
||||
Enabled = enabled,
|
||||
HalfWidth = halfWidth,
|
||||
DataSource = nodes
|
||||
};
|
||||
|
||||
Infos.Add(info);
|
||||
Dictionary.TryAdd(info.DataPropertyName, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user