.desiner.cs
namespace WindowsFormsApplication1
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.filterControl1 = new DevExpress.XtraEditors.FilterControl();
this.gridControl1 = new DevExpress.XtraGrid.GridControl();
this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
this.gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn();
this.repositoryItemTreeListLookUpEditGroup = new DevExpress.XtraEditors.Repository.RepositoryItemTreeListLookUpEdit();
this.repositoryItemTreeListLookUpEdit1TreeList = new DevExpress.XtraTreeList.TreeList();
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListLookUpEditGroup)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListLookUpEdit1TreeList)).BeginInit();
this.SuspendLayout();
//
// filterControl1
//
this.filterControl1.Cursor = System.Windows.Forms.Cursors.Arrow;
this.filterControl1.Dock = System.Windows.Forms.DockStyle.Left;
this.filterControl1.Location = new System.Drawing.Point(0, 0);
this.filterControl1.Name = "filterControl1";
this.filterControl1.Size = new System.Drawing.Size(215, 451);
this.filterControl1.SourceControl = this.gridControl1;
this.filterControl1.TabIndex = 0;
this.filterControl1.Text = "filterControl1";
//
// gridControl1
//
this.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridControl1.Location = new System.Drawing.Point(215, 0);
this.gridControl1.MainView = this.gridView1;
this.gridControl1.Name = "gridControl1";
this.gridControl1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
this.repositoryItemTreeListLookUpEditGroup});
this.gridControl1.Size = new System.Drawing.Size(516, 451);
this.gridControl1.TabIndex = 1;
this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
this.gridView1});
//
// gridView1
//
this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
this.gridColumn1,
this.gridColumn2});
this.gridView1.GridControl = this.gridControl1;
this.gridView1.Name = "gridView1";
this.gridView1.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True;
this.gridView1.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Top;
//
// gridColumn1
//
this.gridColumn1.Caption = "Group Name";
this.gridColumn1.FieldName = "groupName";
this.gridColumn1.Name = "gridColumn1";
this.gridColumn1.Visible = true;
this.gridColumn1.VisibleIndex = 0;
//
// gridColumn2
//
this.gridColumn2.Caption = "Group";
this.gridColumn2.ColumnEdit = this.repositoryItemTreeListLookUpEditGroup;
this.gridColumn2.FieldName = "groupCode";
this.gridColumn2.FieldNameSortGroup = "By Code";
this.gridColumn2.FilterMode = DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
this.gridColumn2.Name = "gridColumn2";
this.gridColumn2.Visible = true;
this.gridColumn2.VisibleIndex = 1;
//
// repositoryItemTreeListLookUpEditGroup
//
this.repositoryItemTreeListLookUpEditGroup.AutoHeight = false;
this.repositoryItemTreeListLookUpEditGroup.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.repositoryItemTreeListLookUpEditGroup.DisplayMember = "name";
this.repositoryItemTreeListLookUpEditGroup.Name = "repositoryItemTreeListLookUpEditGroup";
this.repositoryItemTreeListLookUpEditGroup.TreeList = this.repositoryItemTreeListLookUpEdit1TreeList;
this.repositoryItemTreeListLookUpEditGroup.ValueMember = "id";
//
// dataTableBindingSource
//
//
// repositoryItemTreeListLookUpEdit1TreeList
//
this.repositoryItemTreeListLookUpEdit1TreeList.KeyFieldName = "id";
this.repositoryItemTreeListLookUpEdit1TreeList.Location = new System.Drawing.Point(0, 0);
this.repositoryItemTreeListLookUpEdit1TreeList.Name = "repositoryItemTreeListLookUpEdit1TreeList";
this.repositoryItemTreeListLookUpEdit1TreeList.OptionsBehavior.EnableFiltering = true;
this.repositoryItemTreeListLookUpEdit1TreeList.OptionsView.ShowIndentAsRowStyle = true;
this.repositoryItemTreeListLookUpEdit1TreeList.ParentFieldName = "pId";
this.repositoryItemTreeListLookUpEdit1TreeList.Size = new System.Drawing.Size(400, 200);
this.repositoryItemTreeListLookUpEdit1TreeList.TabIndex = 0;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(731, 451);
this.Controls.Add(this.gridControl1);
this.Controls.Add(this.filterControl1);
this.Name = "Form2";
this.Text = "Form2";
((System.ComponentModel.ISupportInitialize)(this.gridControl1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListLookUpEditGroup)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.repositoryItemTreeListLookUpEdit1TreeList)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DevExpress.XtraEditors.FilterControl filterControl1;
private DevExpress.XtraGrid.GridControl gridControl1;
private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn1;
private DevExpress.XtraGrid.Columns.GridColumn gridColumn2;
private DevExpress.XtraEditors.Repository.RepositoryItemTreeListLookUpEdit repositoryItemTreeListLookUpEditGroup;
private DevExpress.XtraTreeList.TreeList repositoryItemTreeListLookUpEdit1TreeList;
}
}
.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.repositoryItemTreeListLookUpEditGroup.DataSource = getDataTable();
this.repositoryItemTreeListLookUpEdit1TreeList.DataSource = getDataTable();
gridControl1.DataSource = GetItemList();
}
private DataTable getDataTable()
{
var dataTable = new DataTable();
dataTable.Columns.Add("id", typeof(int));
dataTable.Columns.Add("pId", typeof(int));
dataTable.Columns.Add("name", typeof(string));
dataTable.Rows.Add(1, null, "Name1");
dataTable.Rows.Add(2, null, "Name2");
dataTable.Rows.Add(3, null, "Name3");
dataTable.Rows.Add(4, 1, "Name1.1");
dataTable.Rows.Add(5, 1, "Name1.2");
dataTable.Rows.Add(6, 3, "Name3.1");
dataTable.Rows.Add(7, 3, "Name3.2");
dataTable.Rows.Add(8, 5, "Name1.2.1");
return dataTable;
//var treeListLookUpEdit = new TreeListLookUpEdit();
//var properties = treeListLookUpEdit.Properties;
//properties.DataSource = dataTable;
//properties.DisplayMember = "Name";
//properties.ValueMember = "ID";
//var treeList = properties.TreeList;
//treeList.KeyFieldName = "ID";
//treeList.ParentFieldName = "Parent_ID";
//treeList.RootValue = DBNull.Value;
//Controls.Add(treeListLookUpEdit);
//treeListLookUpEdit.Size = treeListLookUpEdit.CalcBestSize();
}
private List<ItemModel> GetItemList()
{
return new List<ItemModel>()
{
new ItemModel(){ groupName="Group Name 1", groupCode= "Name3"},
new ItemModel(){ groupName="Group Name 2", groupCode= "Name2"},
new ItemModel(){ groupName="Group Name 3", groupCode= "Name3"},
};
}
}
}