Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Getting a simple program to work correctly  (Read 448 times)

0 Members and 1 Guest are viewing this topic.

Hector

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Getting a simple program to work correctly
« on: June 05, 2010, 03:27:58 AM »
I have a simple app with two columns. I want to have checkboxes in the second one. I can't seem to find the NodeControl collection in either the designer or in code.

The code is very simple:

        private void Form1_Load(object sender, EventArgs e)
        {
            //CreateColumns();
            CreateNodes();
            //FillColumns();

            tvWorkFlow.ExpandAll();
        }

        private void CreateNodes()
        {
            tvWorkFlow.Nodes.Clear();

            for (int i = 0; i < 5; i++)
            {
                var node = new TreeListViewNode("Node Number " + i);

                tvWorkFlow.Nodes.Add(node);
            }
        }

The ContentType on the "Active" column is set to CheckBox.

I've attached the solution to this post. Could you help me get the checkboxes on that second column?

Thanks!

Ruslan

  • Flexible TreeView Team
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 496
Re: Getting a simple program to work correctly
« Reply #1 on: June 05, 2010, 06:08:24 AM »
Hello and welcome to forums!

You can create the treeview like that in a minute. Please see the attached sample and screenshot.
To do that, you need to open the VS form designer and then:
 * open the Columns treeview designer and add 2 columns with Text property equals to 'Action Name' and 'Active' respectively.
 * open the NodeControls treeview designer and add the NodeTextBox and NodeCheckBox node controls. Then attach those node controls to a column where it will be displayed using the ColumnId node control property. Every column has the Id property with unique index and this index will be stored in the node control`s ColumnId property. The ColumnId node control property has designer so you need only select the appropriate column from the list.
That is all what you need to do in designer.

Then fill the treeview with nodes:
Code: [Select]
for(int i = 0; i < 5; i++)
{
  Node node = new Node("Node Number "+i.ToString());
  node.AttachTo(flexibleTreeView1);
}
« Last Edit: June 05, 2010, 09:24:35 AM by Ruslan »

Hector

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
Re: Getting a simple program to work correctly
« Reply #2 on: June 06, 2010, 12:00:41 AM »
D'OH! The reason the code didn't work before, was because I was using someone else's control.  ::) That will teach me to do evaluations late at night.

Setting the checkboxes was quite straight-forward. Is there a way to center the checkboxes in the column? I tried different alignment settings, to no avail.

Ruslan

  • Flexible TreeView Team
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 496
Re: Getting a simple program to work correctly
« Reply #3 on: June 06, 2010, 05:25:57 AM »
Is there a way to center the checkboxes in the column? I tried different alignment settings, to no avail.

Of course you can align node controls within a column or treeview without columns as you need. To do that, enable the FillFreeSpace node control property and then change the TextAlign node control property to the alignment you need.
Please read this topic (FillFreeSpace chapter) for details.
 

Copyright © 2006-2012 ARMSoft. All rights reserved.