Hi,
i need a simple way to have a tree of data that could be edited by the user. Each node (on each level of the tree) has 3 columns with data. Just like this:
description ------ Additional text ---------- yes/no+----- description of node2 ---------- add.text node2 ----------- yes/no.............+--------- desc. of node 2.1 ---------- addtext node 2.1----------- yes/no+----- description of node3 ---------- add.text node2 ----------- yes/no+----- description of node4 ---------- add.text node2 ----------- yes/no
Just like a 3 column-grid with hierarchical data.
Now, this works with the UltraTree + a ColumSet. To have the Header just once i can use the OutlookExpress style.
This way i'm adding nodes and subnodes and it looks just fine.
BUT:
now if you select the first node you cannot move down to the next node with CursorDown. It seems, that now Cursor Up/Down is jumping only to sibling nodes (nodes at the same level). This Tree doesn't behave like a tree anymore!
I can see the Newsreader Example. Here it works like expected but: This example uses a dataset (maybe it works because of that?) and it doesn't allow editing of the cell-data (mabe it works because of that?)
Question:
How can i build a Tree with Columns and hierarchical data while at the same time let it behave like a tree? Cursor up/down should move thru all expanded Nodes on all levels. Mabe Cursor left/right should collapse/expand the nodes.
But i need to edit the data in the cells - so maybe left/right is blocked for moving thru the cells (but it would be nice to change that for example to ENTER or TAB for special cases)
Thanks a lot
if someone looks for a small work-around here is what i'm trying now (it works, i will see how good and if i can make some kind of subclass of ultraTree with this as default:
Purpose:- User should be able to have a cell active but at the same time select thru all nodes (on each level) just like you expect from a normal tree (with cursor up/down)- the current row should still be active after selecting a different node
Solution:(my tree is named "treeRechte")
private string FMerkColumnKey; private bool FIsKeyDown;
private void treeRechte_KeyDown(object sender, KeyEventArgs e) { if ((e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Up)) { FIsKeyDown = true; FMerkColumnKey = treeRechte.ActiveCell.Column.Key; treeRechte.ActiveCell = null; }
// Enter to open/close the editor
if (e.KeyCode == Keys.Enter) { if (treeRechte.ActiveCell.IsInEditMode) { treeRechte.ActiveCell.EndEdit(false); //false = nicht cancelled } else { treeRechte.ActiveCell.BeginEdit(); } }
private void treeRechte_AfterSelect(object sender, SelectEventArgs e) { if (FIsKeyDown) { FIsKeyDown = false; treeRechte.ActiveCell = treeRechte.ActiveNode.Cells[FMerkColumnKey]; } }
Thanks! You are right! If i hit Ctrl+Space the Cell is not highlighted anymore and i can walk thru all nodes.
But that's a problem, because i like my users to quickly edit values in a column thru all entries. So, if i disable the cell - how can the user see in which column he is? How can he enter the edit-mode again?
Ctrl+Space is not an option because that's not "common sense". Nobody knows that and i'm in a position to write a GUI that has to be "nice, clean, 'sexy'" and is "as easy to use as possible without reading books"
Anyone allready having code-samples on how to make a really good editor with the UltraTree? Are there any derived classes of this UltraTree that have a better handling for this to avoid coding a lot of tricks and workarounds again and again?
I think what is happening is that when you press the down arrow key, you have an ActiveCell, which will navigate to the cell below, but only until the end of the nodes collection is reached, i.e., it will not attempt to navigate to the next visible "row", because that row is in a different nodes collection. Try pressing Ctrl+Space to get out of cell navigation mode, and see if you can then navigate past the end of the child Nodes collection; if so then this is what is happening.
You might be able to handle AfterCellExitMode and deactivate the cell, so that the node is active instead, and then you will be able to navigate downward past the end of the child Nodes collection.