Ejemplo n.º 1
0
    public Form1()
    {
        this.ClientSize = new System.Drawing.Size(700, 500);
        DevExpress.XtraTreeList.TreeList treeList1 = new DevExpress.XtraTreeList.TreeList();
        this.Controls.Add(treeList1);
        treeList1.Dock = DockStyle.Fill;
        var permissions = new System.Collections.Generic.List <TestClass>();

        permissions.Add(new TestClass()
        {
            Id = 1, Description = "Desc1"
        });
        permissions.Add(new TestClass()
        {
            Id = 99, Description = "Desc2"
        });
        // Your code
        RepositoryItemLookUpEdit rep = new RepositoryItemLookUpEdit();

        rep.TextEditStyle = TextEditStyles.DisableTextEditor;
        //rep = new RepositoryItemComboBox();
        //rep.Items.AddRange(new SecuredObject<QuestionnaireCategory>().PermissionType);
        //rep.Items.AddRange(new object[] { "A", "B", "C" });
        treeList1.RepositoryItems.Add(rep);
        TreeListColumn disciplineColumn = treeList1.Columns.Add();

        disciplineColumn.Caption   = "Discipline";
        disciplineColumn.Visible   = true;
        disciplineColumn.FieldName = "Entity.Description";
        disciplineColumn.OptionsColumn.AllowEdit = false;
        TreeListColumn permissionColumn = treeList1.Columns.Add();

        permissionColumn.Caption = "Permissie";
        permissionColumn.Visible = true;
        permissionColumn.Name    = "Permission";
        //permissionColumn.FieldName = "PermissionType";
        permissionColumn.UnboundType = UnboundColumnType.Object;
        permissionColumn.ColumnEdit  = rep;
        //permissionColumn.OptionsColumn.ReadOnly = false;
        //permissionColumn.OptionsColumn.AllowEdit = true;
        rep.DataSource    = permissions;
        rep.DisplayMember = "Description";
        rep.ValueMember   = "Id";
        rep.Name          = "ola";
        rep.ThrowExceptionOnInvalidLookUpEditValueType = true;
        // End Your code
        bool unBoundMode = true;

        if (unBoundMode)
        {
            treeList1.AppendNode(new object[] { "Item1", 1 }, -1);
            treeList1.AppendNode(new object[] { "Item2", 99 }, -1);
        }
        else
        {
            treeList1.DataSource       = permissions;
            permissionColumn.FieldName = "Id";
        }
    }
Ejemplo n.º 2
0
        public static void InitTree(DevExpress.XtraTreeList.TreeList treeList)
        {
            treeList.Nodes.Clear();
            treeList.AppendNode("全部", -1).SetValue(0, "全部");
            treeList.AppendNode("事件", -1).SetValue(0, "事件");
            DevExpress.XtraTreeList.Nodes.TreeListNode node1 = treeList.AppendNode("麻药", -1);
            node1.SetValue(0, "麻药");
            treeList.AppendNode("用药", -1).SetValue(0, "用药");
            treeList.AppendNode("输血", -1).SetValue(0, "输血");
            treeList.AppendNode("输液", -1).SetValue(0, "输液");
            treeList.AppendNode("输氧", -1).SetValue(0, "输氧");
            treeList.AppendNode("岀液", -1).SetValue(0, "岀液");
            treeList.AppendNode("手术", -1).SetValue(0, "手术");
            treeList.AppendNode("麻醉", -1).SetValue(0, "麻醉");
            treeList.AppendNode("插管", -1).SetValue(0, "插管");
            treeList.AppendNode("置管", -1).SetValue(0, "置管");
            treeList.AppendNode("拔管", -1).SetValue(0, "拔管");

            DevExpress.XtraTreeList.Nodes.TreeListNode node2 = treeList.AppendNode("呼吸", -1);
            node2.SetValue(0, "呼吸");

            treeList.AppendNode("附记项目", -1).SetValue(0, "附记项目");
            treeList.AppendNode("其他", -1).SetValue(0, "其他");
            treeList.AppendNode("诱导", -1).SetValue(0, "诱导");
            treeList.AppendNode("镇痛", -1).SetValue(0, "镇痛");
            treeList.AppendNode("抗生素", -1).SetValue(0, "抗生素");
            treeList.AppendNode("特殊材料", -1).SetValue(0, "特殊材料");

            treeList.AppendNode("吸入麻药", node1).SetValue(0, "吸入麻药");
            treeList.AppendNode("局部麻药", node1).SetValue(0, "局部麻药");
            treeList.AppendNode("静脉麻药", node1).SetValue(0, "静脉麻药");
            treeList.AppendNode("辅助呼吸", node2).SetValue(0, "辅助呼吸");
            treeList.AppendNode("控制呼吸", node2).SetValue(0, "控制呼吸");
            treeList.AppendNode("自主呼吸", node2).SetValue(0, "自主呼吸");
        }
Ejemplo n.º 3
0
        private void CreateTreeViewSimple()
        {
            DevExpress.XtraTreeList.TreeList treeList1 = new DevExpress.XtraTreeList.TreeList()
            {
                Dock = WF.DockStyle.Fill
            };
            DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
            DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn2 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
            treeList1.Parent = this;
            this.Controls.Add(treeList1);               // Musí být dřív než se začne pracovat s daty!!!
            _TreeList = treeList1;


            ((System.ComponentModel.ISupportInitialize)(treeList1)).BeginInit();
            this.SuspendLayout();

            treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { treeListColumn1, treeListColumn2 });

            treeListColumn1.OptionsColumn.AllowEdit = false;
            treeListColumn1.OptionsColumn.AllowSort = false;

            treeList1.OptionsView.FocusRectStyle = DrawFocusRectStyle.RowFocus;

            treeList1.BeginUnboundLoad();
            var node0 = treeList1.AppendNode(new object[] { "Node 1", "Popisek" }, -1);

            var node1 = treeList1.AppendNode(new object[] { "Node 11", "Popisek" }, 0);
            var node2 = treeList1.AppendNode(new object[] { "Node 2", "Popisek" }, -1);
            var node3 = treeList1.AppendNode(new object[] { "Node 21", "Popisek" }, 2);
            var node4 = treeList1.AppendNode(new object[] { "Node 22", "Popisek" }, 2);
            var node5 = treeList1.AppendNode(new object[] { "Node 3", "Popisek" }, -1);
            var node6 = treeList1.AppendNode(new object[] { "Node 31", "Popisek" }, 5);

            //            treeList1.SelectImageList = _Images16;                    // Odkazuje se na node.ImageIndex nebo SelectImageIndex: reprezentuje první ikonu, když prvek je/není Selected
            treeList1.StateImageList = _Images16;                     // Odkazuje se na node.StateImageIndex: reprezentuje statickou ikonu u Node

            node0.CheckState = CheckState.Checked;

            node0.ImageIndex       = -1;             // Ikona když node NENÍ Selected, bere se z SelectImageList. Pokud není nastaveno, je zde 0 a bere se první ikona z Listu.
            node0.SelectImageIndex = 1;              // Ikona když node JE Selected, bere se z SelectImageList
            node0.StateImageIndex  = 3;              // Trvalá ikona za první ikonou, bere se z StateImageList, nemění se při Selected
            node0.Expanded         = true;

            node1.ImageIndex       = -1;             // Ikona když node NENÍ Selected, bere se z SelectImageList. Pokud není nastaveno, je zde 0 a bere se první ikona z Listu.
            node1.SelectImageIndex = -1;
            node1.StateImageIndex  = 5;

            node2.StateImageIndex  = 5;
            node2.SelectImageIndex = 13;

            node3.StateImageIndex  = 11;
            node3.SelectImageIndex = 14;

            node4.StateImageIndex  = 18;
            node4.SelectImageIndex = 16;


            treeList1.EndUnboundLoad();

            treeList1.OptionsView.AutoWidth = false;

            treeListColumn1.Caption      = "treeListColumn1";
            treeListColumn1.FieldName    = "treeListColumn1";
            treeListColumn1.Name         = "treeListColumn1";
            treeListColumn1.Visible      = true;
            treeListColumn1.VisibleIndex = 0;
            treeListColumn1.Width        = 122;

            ((System.ComponentModel.ISupportInitialize)(treeList1)).EndInit();
            this.ResumeLayout(false);



            treeList1.ViewStyle = TreeListViewStyle.TreeView;
        }