Search code examples
c#devexpressdevexpress-windows-ui

How to make a "TreeView"?


How to make using DevExpress:
1. TreeView based on the database?
2. TreeView was synchronized with the database?
Changed the contents of the line -> the database was updated.

  Dragged the subordinate line to another node -> the database was updated.

3. In order to drag-and-drop the TreeView elements between nodes.

How to solve all the problems with the help of "designer" or programming.

On the "1" question, I realized that we need to create a TreeList, and then set the TreeList.ViewStyle property to TreeView.
So it is written in the documentation

I created the TreeList.

Where can I change the property TreeList.ViewStyle? How to make a TreeView?

Project - link


Solution

  • Please take a look at the How to make the TreeList control look like a TreeView example which illustrates how to achieve your goal.

    Check the TreeList's TreeView Style documentation and you can change the view by setting TreeList.ViewStyle Property

    Example:

    private void Form1_Load(object sender, EventArgs e) {
                treeList1.ForceInitialize();
    
                treeList1.Appearance.FocusedCell.BackColor = System.Drawing.SystemColors.Highlight;
                treeList1.Appearance.FocusedCell.ForeColor = System.Drawing.SystemColors.HighlightText;
                treeList1.OptionsBehavior.Editable = false;
    
                treeList1.ViewStyle = DevExpress.XtraTreeList.TreeListViewStyle.TreeView;
            }