locked
This kind of treeview in C# ?

    Question

  • Hello,

    I am wondering about this thing. My friend created UI (like on screenshot), using c++ and Qt library. I want to reproduce it in C#, anyway without using Qt library. Is it possible? I am not sure if it is a treeview, was playing with standard treeview control and couldn't reproduce it.

    In value tab, user can set enabled/disabled with combobox, and also provide any text (with textbox I think).

    Does anyone know how to achieve it?

    Thanks in advance,

    panqnik

    Tuesday, February 28, 2012 4:47 PM

Answers

  • Hi panqnik,

    Welcome to the MSDN forum.

    It seems that you are looking for a TreeListView. If so, you can try this sample. The TreeListView in this sample is a hybrid control. It blends a TreeView with the ContainerListView control (another control in this sample), allowing the first column to behave as a tree.

    Part of code:

    TreeListView tlv = new TreeListView();
    tlv.SmallImageList = smallImageList;
    tlv.VisualStyles = true;
    
    // Add column headers
    ToggleColumnHeader tch = new ToggleColumnHeader();
    tch.Text = "Tree Column";
    tlv.Columns.Add(tch);
    tch = new ToggleColumnHeader();
    tch.Text = "Column 2";
    tlv.Columns.Add(tch);
    tch = new ToggleColumnHeader();
    tch.Text = "Column 3";
    tlv.Columns.Add(tch);
    
    // Add tree nodes
    TreeListNode tln = new TreeListNode();
    tln.Text = "Test";
    tln.ImageIndex = 1;
    tln.SubItems.Add("Sub Item 1");
    tln.SubItems.Add("Sub Item 2");
    
    TreeListNode tln2 = new TreeListNode();
    tln2.Text = "Child 1";
    tln2.ImageIndex = -1; // Setting to -1 will suppress icon
    tln2.SubItems.Add("Sub Item 1.1");
    tln2.SubItems.Add("Sub Item 2.1");
    tln2.Nodes.Add(tln2);
    
    tlv.Nodes.Add(tln);
    
    tln = new TreeListNode();
    tln.Text = "Second Test";
    tln.ImageIndex = 1;
    tln.SubItems.Add("Test Item");
    tln.SubItems.Add("Test Item");
    
    tlv.Nodes.Add(tln);
    

    Some related links may help you too.
    TreeView with Columns
    http://www.codeproject.com/Articles/23746/TreeView-with-Columns
    TreeListView
    http://www.codeproject.com/Articles/3225/TreeListView

    Have a nice day.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by panqnik Friday, October 26, 2012 12:45 PM
    Thursday, March 01, 2012 7:58 AM

All replies

  • Hi panqnik,

    Welcome to the MSDN forum.

    It seems that you are looking for a TreeListView. If so, you can try this sample. The TreeListView in this sample is a hybrid control. It blends a TreeView with the ContainerListView control (another control in this sample), allowing the first column to behave as a tree.

    Part of code:

    TreeListView tlv = new TreeListView();
    tlv.SmallImageList = smallImageList;
    tlv.VisualStyles = true;
    
    // Add column headers
    ToggleColumnHeader tch = new ToggleColumnHeader();
    tch.Text = "Tree Column";
    tlv.Columns.Add(tch);
    tch = new ToggleColumnHeader();
    tch.Text = "Column 2";
    tlv.Columns.Add(tch);
    tch = new ToggleColumnHeader();
    tch.Text = "Column 3";
    tlv.Columns.Add(tch);
    
    // Add tree nodes
    TreeListNode tln = new TreeListNode();
    tln.Text = "Test";
    tln.ImageIndex = 1;
    tln.SubItems.Add("Sub Item 1");
    tln.SubItems.Add("Sub Item 2");
    
    TreeListNode tln2 = new TreeListNode();
    tln2.Text = "Child 1";
    tln2.ImageIndex = -1; // Setting to -1 will suppress icon
    tln2.SubItems.Add("Sub Item 1.1");
    tln2.SubItems.Add("Sub Item 2.1");
    tln2.Nodes.Add(tln2);
    
    tlv.Nodes.Add(tln);
    
    tln = new TreeListNode();
    tln.Text = "Second Test";
    tln.ImageIndex = 1;
    tln.SubItems.Add("Test Item");
    tln.SubItems.Add("Test Item");
    
    tlv.Nodes.Add(tln);
    

    Some related links may help you too.
    TreeView with Columns
    http://www.codeproject.com/Articles/23746/TreeView-with-Columns
    TreeListView
    http://www.codeproject.com/Articles/3225/TreeListView

    Have a nice day.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by panqnik Friday, October 26, 2012 12:45 PM
    Thursday, March 01, 2012 7:58 AM
  • Hi panqnik,

    How's it going? Do you have any updates about the previous issue?


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 09, 2012 4:27 AM
  • Hello Bob,

    I fixed it in this way:I have created tree view on left side of window, and groupbox with some items on right side.

    When user click on node from tree view, info with properties is showed in items in groupbox.

    It isn't what I wanted to achieve, however it works fine :)

    Thanks for Your attention,

    panqnik

    Friday, March 09, 2012 4:33 AM
  • Hi panqnik,

    If you have any difficulty in future programming, we welcome you to post here again. There are many enthusiastic community members here to provide their help and suggestions.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 09, 2012 4:36 AM
  • Hi Bob,

    In this case, I have another problem:

    I am creating an event queue (actions from program are executing in queue, in LIFO (Last-In-Last-Out).

    I am using Stack to it, already implemented everything and it works. However, I want to add life time of even:

    If from time when object were inserted into stack elapesed for example 2 seconds, it will be removed from stack.

    I already made it works, but maybe there is another way to do it: when a object is inserted into Stack, it has

    current GetTickCount value. When stack "processing" object, I am checking if GetTickCount() + life time is bigger

    than current GetTickCount(), if so, I am skipping this object.

    I hope You undrestood what I mean, english isn't my native language :(

    Regards,

    panqnik

    Friday, March 09, 2012 4:43 AM
  • Hi panqnik,

    It would be better if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.
    Thanks for your understanding.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 12, 2012 2:14 AM