The standard .net TreeView control allows you to code a solution that enables the selection of an entire row in the treeview control when a node is selected, rather than just the node text itself:
treeView.DrawNode += new DrawTreeNodeEventHandler(treeView_DrawNode);
void treeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
if ((e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected)
...
// draw node text TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, e.Node.Bounds, nodeForeColor, TextFormatFlags.Left | TextFormatFlags.Top);
Is there any way to do this with an UltraTree infragistics control? Currently I can't see a way to do it.
Thanks.
Hi,
You can achieve this in both the UltraTree and the inbox TreeView control just using properties like so:
this.ultraTree1.FullRowSelect = true; this.ultraTree1.ShowLines = false; this.ultraTree1.ShowRootLines = false; this.treeView1.FullRowSelect = true; this.treeView1.ShowLines = false; this.treeView1.ShowRootLines = false;
What about if you want to have the +/- displayed, as in "treeView1.ShowRootLines = true" ? ... it seems to work with the .net one, but not with the infragistics one... or am I missing something here?
(However, as I said, I did have to hand craft the code that I detailed in post 1 in order to do this. Just can't see a way to replicate it for the infragistics control)
Hm, that's odd. I thought that the UltraTree was supposed to work like the MS tree in this respect, but you are correct, our tree does not allow FullRowSelect when ShowRootLines is on and the inbox tree does. That's probably not something we can change at this point.
The only way to make this work would be to use a DrawFilter or a CreationFilter (or possibly both). It could be pretty tricky, especially if you haven't used DrawFilters or CreationFilters before.
Is it a requirement that the selection extend into the expansion indicator? Or do you just need the node to extend all the way to the left? I think this would be very tricky, especially if there is a horizontal scrollbar active.
Hi John,
Oh, sorry. If you are adding your nodes to the tree in code, then you would have to set up the column's for OutlookExpress style. So what you do is use the tree.ColumnSettings.RootColumnSet. Add a column to it and I think that should do it. You might have to also set the NodeTextColumn on the ColumnSet to the column you added, but I think if you don't set it, it just picks up the first column, so you may not need to.
If you bind the tree to a data source of some kind, it will create the columns for you automatically.
I think I must be missing something here... as when I choose outlookexpress as the viewstyle I no longer see any of the nodes that are visible in other styles - ?
(In answer to the previous question, I have the feeling that the man age ment may be wanting something that this particular control is not really suited to TBH)
Oh... maybe you could switch to OutlookExpress ViewStyle. That would get you the full-row selection that you want. Of course, it also means that the tree will display with columns, so that may not fit your requirements.