Topic: Grid Tree Column - InsertTreeColumn

Hello fellow MVD users!

I read in the help files that the Grid component has the option to add a Tree column to it:

Form1.grid.InsertTreeColumn(0);

However there isn't more information of how can one tell it which column is the one that holds the hierarchy (ParentID) or if there needs to be some loop involved how to tell it that a row is a child of another row etc.

Does anybody know how to do so?

I ask because the TreeView component itself is a bit limited with how the "in-line" editing works (no dropdowns for cells etc.) nor can I manually "feed" it SQL like I can do with the Grid component by utilizing dbSQL.

As always thank you in advance for your time!

Re: Grid Tree Column - InsertTreeColumn

Hi


You can only work with the added column manually.
After adding the column, you can use AddRow and AddChildRow to add the corresponding rows.
Then assign values to them using Cells[x,y]. Some column properties are also available.
You cannot add data to this column using dbSql. Or rather, it will work for other columns and you will get a mess.
That's what I know.

Re: Grid Tree Column - InsertTreeColumn

Hi Sparrow!

As always, thank you so much for your help!

I was testing what you said but from my tests the AddChildRow is a TreeView only method so I get an error when I use it in a Table Grid component.

Is there a different way to indicate an added row is a child of a row in a Table Grid component (when utilizing the InsertTreeColumn)?

Thank you again!

Re: Grid Tree Column - InsertTreeColumn

Look closely at the error or show an example of the script.

Re: Grid Tree Column - InsertTreeColumn

You are correct! (obviously cool )

I was missing a parameter (position - crLast in my case) and it works!

Form1.TableGrid1.Columns.InsertTreeColumn(0);
Form1.TableGrid1.AddRow(1);
Form1.TableGrid1.AddChildRow(0,crLast);

Thanks again!