C# DevExpress TreeListLookUpEdit 绑定数据源下拉窗体
作者:C/S框架网|www.cscode.ne  发布日期:2021/06/03 16:29:17
  C# DevExpress TreeListLookUpEdit 绑定数据源下拉窗体


贴图图片-treelistlookupedit




C# Code:

/// <summary>
/// 绑定财务科目树
/// </summary>
/// <param name="lue">TreeListLookUpEdit组件</param>
/// <param name="imageList">图标</param>
public static void BoundAccountItem(TreeListLookUpEdit lue, ImageList imageList, DataTable treeData)
{
  
//创建TreeList的列
  
TreeListColumn col_Popup_CategoryName = new TreeListColumn();
  col_Popup_CategoryName.Caption
= "科目名称";
  col_Popup_CategoryName.FieldName
= tb_AccountItems.ItemName;
  col_Popup_CategoryName.Name
= "col_Popup_ItemName";
  col_Popup_CategoryName.Visible
= true;
  col_Popup_CategoryName.VisibleIndex
= 0;
  col_Popup_CategoryName.Width
= 130;
  
  
//TreeListLookUpEdit.Properties
  
lue.Properties.NullText = "";
  lue.Properties.DisplayMember
= tb_AccountItems.ItemName;
  lue.Properties.ValueMember
= tb_AccountItems.ItemID;
  
  TreeList tree
= lue.Properties.TreeList;
  tree.StateImageList
= imageList;
  tree.Columns.Clear();
  tree.Columns.AddRange(
new DevExpress.XtraTreeList.Columns.TreeListColumn[] { col_Popup_CategoryName });
  tree.OptionsView.ShowSummaryFooter
= false;
  
  tree.KeyFieldName
= tb_AccountItems.ItemID;//设置主键
  
tree.ParentFieldName = tb_AccountItems.ParentID;//设置父级主键
  
tree.RootValue = "";//顶级树结点的值
  
tree.DataSource = treeData.Copy();
  
  DevStyle.SetTreeListSelectStyle(tree);
  DevTreeListView.SetImageIndex(tree,
null, 1, 0);
  
  tree.ExpandAll();
}

//来源:C/S框架网 | www.csframework.com | QQ:23404761





C/S框架网|原创精神.创造价值.打造精品

扫一扫加微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务

上一篇 下一篇