#region TreeList设置
// 禁用排序
foreach (TreeListColumn col in treeList1.Columns)
{
col.OptionsColumn.AllowSort = false;
}
// 禁用指示器
treeList1.OptionsView.ShowIndicator = false;
// 禁用表头右键
treeList1.OptionsMenu.EnableColumnMenu = false;
// 禁止编辑
colName.OptionsColumn.AllowEdit = false;
// 绑定key
treeList1.KeyFieldName = nameof(VMDept.Sysid);
treeList1.ParentFieldName = nameof(VMDept.ParentId);
// 选中整行
treeList1.OptionsSelection.EnableAppearanceFocusedCell = false;
treeList1.OptionsSelection.EnableAppearanceFocusedRow = true;
//在获得焦点的Cell上,是否显示焦点框架。默认为True
treeList1.OptionsView.FocusRectStyle = DrawFocusRectStyle.None;
// 启用搜索框
treeList1.OptionsFind.AlwaysVisible = true;
treeList1.OptionsFind.AllowFindPanel = true;
treeList1.OptionsFind.ShowSearchNavButtons = true;
// 显示关闭按钮
treeList1.OptionsFind.ShowCloseButton = false;
// 显示查找按钮
treeList1.OptionsFind.ShowFindButton = false;
treeList1.OptionsFind.FindNullPrompt = "请输入部门名称";
//TreeList 边框
treeList1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
//默认显示下拉三角形样式,设置TreeList的两个皮肤属性即可变成连接虚线
treeList1.LookAndFeel.UseDefaultLookAndFeel = false;
treeList1.LookAndFeel.UseWindowsXPTheme = true;
treeList1.OptionsView.ShowHorzLines = true; //是否显示水平线。默认为True;
treeList1.OptionsView.ShowVertLines = true; //是否显示垂直线。默认为True;
treeList1.OptionsView.ShowColumns = false; //是否显示列标题。默认为True;
#region 右键汉化
treeList1.PopupMenuShowing += (sender, e) =>
{
foreach (DevExpress.Utils.Menu.DXMenuItem item in e.Menu.Items)
{
if (item.Caption == "Full Expand")
{
item.Caption = "全部展开";
}
if (item.Caption == "Expand")
{
item.Caption = "展开";
}
if (item.Caption == "Collapse")
{
item.Caption = "折叠";
}
if (item.Caption == "Full Collapse")
{
item.Caption = "全部折叠";
}
}
};
#endregion
#endregion
效果图