none
winform control : Custom TreeView with GridView

    Question

  • I am working on Winform application.

    I want  to add a property to TreeNode property so that I can defind the type of Node.

    Ex. If I select datagrid ,then node should be displayed as Datagrid. Similar to Datagrid column . columntype property.

    Is there any way to do this ?

    I will be really thankfull if anyone has answer.

     

    Thanks.

    Thursday, October 14, 2010 3:35 PM

Answers

  • Hi,

    I think you probably need to develop a customized treeview to have this functionality. Such as the following example demonstrated:

    public class DropDownTreeNode : TreeNode
    {
        // *snip* Constructors go here
       
        private ComboBox m_ComboBox = new ComboBox();
        public ComboBox ComboBox
        {
            get
            {
                this.m_ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                return this.m_ComboBox;
            }
            set
            {
                this.m_ComboBox = value;
                this.m_ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            }
        }
    }

    Instead of combobox you can use datagridview, however this will make the program more complicated.

    http://www.codeproject.com/KB/tree/DropDownTreeView.aspx

    Thanks

    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bin-ze Zhao Thursday, October 21, 2010 7:41 AM
    Monday, October 18, 2010 9:39 AM

All replies

  • I am working on winforms.

    How can I create custom treeview , with each parent and child node as Datagrid ?

    Thanks in advance for any reply.

     

    • Merged by Bin-ze Zhao Tuesday, October 19, 2010 5:40 AM duplicate
    Thursday, October 14, 2010 3:59 PM
  • Hi,

    I think you probably need to develop a customized treeview to have this functionality. Such as the following example demonstrated:

    public class DropDownTreeNode : TreeNode
    {
        // *snip* Constructors go here
       
        private ComboBox m_ComboBox = new ComboBox();
        public ComboBox ComboBox
        {
            get
            {
                this.m_ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                return this.m_ComboBox;
            }
            set
            {
                this.m_ComboBox = value;
                this.m_ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            }
        }
    }

    Instead of combobox you can use datagridview, however this will make the program more complicated.

    http://www.codeproject.com/KB/tree/DropDownTreeView.aspx

    Thanks

    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bin-ze Zhao Thursday, October 21, 2010 7:41 AM
    Monday, October 18, 2010 9:39 AM