 |
|
 |
Hi,
I have a multicolumn treeview application in mind, which should display a couple of small bitmaps (bmp, tif, jpg, whatever...) in columns 2..n (~ 5 columns) - one bitmap per column.
As far as I understand the control(just found it today), it does not provide this option. Columns 2..n are pure text. Right?
Do you plan a version 1.8 which supports that feature?
Anyhow (although already stated many times): GREAT tool!!
U.
|
|
|
|
 |
|
 |
Andrey Hi. Great control, thanks. I guess found 1 error in TreeViewAdv class:
event handler _model_StructureChanged
code
//-------------------------------------
var list = new Dictionary <object, object>();
SaveExpandedNodes(node, list);
ReadChilds(node);
RestoreExpandedNodes(node, list);
//-------------------------------------
I tried to "bind" this control to datatable as shown in SampleApp.DataTableTreeExample and found problem in redrawing nodes after drug and drop operation.
The eye of the problem:
1. SaveExpandedNodes(node, list);
First you save objects links into dictionary
2. ReadChilds(node);
Then you recreate child nodes list
3. RestoreExpandedNodes(node, list);
After this you are trying to compare old objects with new objects like this
list.ContainsKey(node.Tag)
But objects are totaly different. Other objects, other links, list.ContainsKey(node.Tag) == False always.
To fix this error I change code in functions SaveExpandedNodes and RestoreExpandedNodes. New code:
private void RestoreExpandedNodes2(TreeNodeAdv node, Dictionary<object, object> list)
{
if (node.Tag != null && list.ContainsKey((node.Tag as Node).ToString()))
{
node.IsExpanded = true;
foreach (var child in node.Children)
RestoreExpandedNodes2(child, list);
}
}
private void SaveExpandedNodes2(TreeNodeAdv node, Dictionary<object, object> list)
{
if (node.IsExpanded && node.Tag != null)
{
list.Add((node.Tag as Node).ToString(), null);
foreach (var child in node.Children)
SaveExpandedNodes2(child, list);
}
}
I override ToString() method in my DataRowNode:Node class to "generate" unique node identifier (primary key in my circumstance is ok).
Of course you can fix this error in other way.
|
|
|
|
 |
|
|
 |
|
 |
i used IsVisibleValueNeeded and set it to true on one of the children..
(ie : _nodeTextBox.IsVisibleValueNeeded += CheckIndex; )
the treeView renders the child but the parents are not visible..
I want to show the parents visible of that child but i can't find a way
to make them visible again because their IsVisibleValueNeeded is set to false
because checkIndex sets them to false.
Seems like the only way to go is downward and checkIndex on everychild and
if there is a true condition.. this is quadratic solution.
I prefer to just walk back up the tree from that visible child and make
that Node and all it's controls visible.
any thoughts?
|
|
|
|
 |
|
 |
i tried this code in CheckIndex
TreeNodeAdv thisNode = e.Node;
TreeViewAdv parent = (sender as NodeControl).Parent;
parent.EnsureVisible(thisNode);
whenever i e.Value is set to true.
but i get stack overflow...
|
|
|
|
 |
|
 |
It looks like this is supported via NodeCheckBox.ThreeState. However, I don't know how to enable it. Is there a way to turn this on in the FolderBrowser example?
Great control BTW.
|
|
|
|
 |
|
 |
i get object system.string cannot be converted to system.int32
in bindablecontrol.cs 's Value (setting a value)
the textbox comes in as a string but my model datarow
isn't even being hit before i can cast it to an int..
the code in bindablecontrol looks at the binding and determines it to be int32
and doesn't convert the value to an int when setting it..
Can we only bind strings?
|
|
|
|
 |
|
 |
in the FolderBrowser example. unable to check the checkboxes
(using columns is different?)
|
|
|
|
 |
|
 |
In DataTableTreeExample.cs, there is an example of a context menu associated with a TreeViewAdv. However, I would like to have a context menu associated with each NodeControl of the TreeViewAdv. Is it possible to do that ?
|
|
|
|
 |
|
 |
I got the latest code off Source Forge and it doesn't work Well a portion of the code doesn't work. From the Folders Sample when you check a box, the box doesn't draw the check.
|
|
|
|
 |
|
 |
Display column header and click on the bottom part of the header.
First column will be selected instead of ColumnAutoWidth...
public int GetRowAt(Point point)
{
if (point.Y <= _treeView.ColumnHeaderHeight)
return -1;
point = new Point(point.X, point.Y + (_treeView.FirstVisibleRow * _rowHeight) - _treeView.ColumnHeaderHeight);
return point.Y / _rowHeight;
}
|
|
|
|
 |
|
 |
Just in case anyone is looking for better code for the AutoSizeColumn, I have created a function that works a lot like the one that the listview has. This will accept the ColumnHeaderAutoResizeStyle so it can resize to the column header text and/or the node controls. You can also just use the AutoSizeColumns() function so you don't have to iterate through the columns.
NOTE: To install the code, open TreeViewAdv.Draw.cs and add the code to the top of the file. Then simply call TreeViewAdv.AutoSizeColumns(ColumnHeaderAutoResizeStyle) respectively, through your windows form code.
public void AutoSizeColumns(ColumnHeaderAutoResizeStyle headerAutoSize)
{
if (this.Columns.Count <= 0)
throw new Exception("Treeviewadv doesn't contain any columns");
foreach (TreeColumn tc in this.Columns)
this.AutoSizeColumn(tc, headerAutoSize);
}
public void AutoSizeColumn(TreeColumn col, ColumnHeaderAutoResizeStyle headerAutoSize)
{
if (!Columns.Contains(col))
throw new ArgumentException("column is not a part of treeviewadv", "col");
if (headerAutoSize == ColumnHeaderAutoResizeStyle.None)
return;
foreach (TreeNodeAdv tna in this.VisibleNodes)
{
foreach (NodeControlInfo nci in this.GetNodeControls(tna))
{
if (nci.Control.ParentColumn == col)
{
int nWidth = 0;
Size sizeCntrl = nci.Control.GetActualSize(tna, this._measureContext);
if (col.Index == 0)
nWidth += nci.Bounds.X;
if (!sizeCntrl.IsEmpty)
col.Width = Math.Max(col.Width, (sizeCntrl.Width + nWidth));
if (headerAutoSize == ColumnHeaderAutoResizeStyle.HeaderSize)
{
Size sizeText = TextRenderer.MeasureText(col.Header, this._measureContext.Font);
if (!sizeText.IsEmpty)
col.Width = Math.Max(col.Width, sizeText.Width);
}
}
}
}
}
|
|
|
|
 |
|
 |
Thanks. Just what I needed.
I did change to the following so that the columns shrink to fit the data.
Thanks,
Steve
public void AutoSizeColumn(TreeColumn col, ColumnHeaderAutoResizeStyle headerAutoSize)
{
if (!Columns.Contains(col))
throw new ArgumentException("column is not a part of treeviewadv", "col");
if (headerAutoSize == ColumnHeaderAutoResizeStyle.None)
return;
int TempWidth = 0;
foreach (TreeNodeAdv tna in this.VisibleNodes)
{
foreach (NodeControlInfo nci in this.GetNodeControls(tna))
{
if (nci.Control.ParentColumn == col)
{
int nWidth = 0;
Size sizeCntrl = nci.Control.GetActualSize(tna, this._measureContext);
if (col.Index == 0)
nWidth += nci.Bounds.X;
if (!sizeCntrl.IsEmpty)
TempWidth = Math.Max(TempWidth, (sizeCntrl.Width + nWidth));
if (headerAutoSize == ColumnHeaderAutoResizeStyle.HeaderSize)
{
Size sizeText = TextRenderer.MeasureText(col.Header, this._measureContext.Font);
if (!sizeText.IsEmpty)
TempWidth = Math.Max(TempWidth, sizeText.Width); }
}
}
}
col.Width = TempWidth; }
|
|
|
|
 |
|
 |
Added for sort mark textWidth += col.SortMarkSize.Width + 8;
Used textWidth + 3 for excluding "..." in column name
if (headerAutoSize == ColumnHeaderAutoResizeStyle.HeaderSize)
{
Size sizeText = TextRenderer.MeasureText(col.Header, _measureContext.Font);
if (!sizeText.IsEmpty)
{
int textWidth = sizeText.Width;
if (col.SortOrder != SortOrder.None)
textWidth += col.SortMarkSize.Width + 8; tempWidth = Math.Max(tempWidth, textWidth + 3);
}
}
|
|
|
|
 |
|
 |
Hi,
Thanks for providing this code. I am new to this project. I tested AutoSizeColumn, but it does not work in my project. I found that nci.Control.ParentColumn is always null in my project. Can you explain the meaning of ParentColumn?
Also, sometimes VisibleNodes is null too...But it has child nodes...
Please help me. Thanks a lot!
|
|
|
|
 |
|
 |
Hi,
My next question about AutoSizeColumn function is that I sometimes get cross threads error. Does anyone know how to fix it?
Thanks!
|
|
|
|
 |
|
 |
Have u tried the code below that is included with the sourceforge project?
public void AutoSizeColumn(TreeColumn column)
{
if (!Columns.Contains(column))
throw new ArgumentException("column");
DrawContext context = new DrawContext();
context.Graphics = Graphics.FromImage(new Bitmap(1, 1));
context.Font = this.Font;
int res = 0;
for (int row = 0; row < RowCount; row++)
{
if (row < RowMap.Count)
{
int w = 0;
TreeNodeAdv node = RowMap[row];
foreach (NodeControl nc in NodeControls)
{
if (nc.ParentColumn == column)
w += nc.GetActualSize(node, _measureContext).Width;
}
res = Math.Max(res, w);
}
}
if (res > 0)
column.Width = res;
}
|
|
|
|
 |
|
 |
Is it possible to make tree column frozen? To not scroll it. Similar to datagridview behavior?
Kind Regards
Marcin
|
|
|
|
 |
|
 |
I have read another message regarding this but it does not apply/work for me.
All I want to do is add some nodes and see them with a three-state checkbox. I get the checkbox (by adding it to NodeControls) but I cannot check/uncheck it. Plus I do not see the text of the node.
I follow what I see in the Simple example to no success.
Anyone have any cohesive documentation or an example to get this control to work?
|
|
|
|
 |
|
 |
To get text to show up, add a NodeTextBox to NodeControls in the designer, then derive from Aga.Controls.Tree.Node and go crazy in the ToString() override (or just return Text if you want to display the text of the node).
This is generally a good control, but it's not a drop-in. To really get it you have to study its architecture, as well as the designer side of the simple example. For the impatient: derive a class from Node, for every column you want, implement a property, say, public string MyColumn { get { ... } }, then in the designer, put "MyColumn" in the DataPropertyName of the nodeControl, and set up the Column # for that NodeControl. To get icons on your tree items, use a NodeIcon, and point its DataPropertyName at a property of your derived Node class that returns an Image.
To the author: if you put everything in code, even what you'd usually set up inside the designer, it may be a bit easier for people to learn. First time I used it, I didn't even know about the central role that NodeControls play until I had stepped into the drawing code!
(To be fair though, I hadn't read the whole article carefully. My usual approach with code from here is "drop in and see if it works first, read the article for specifics later").modified on Sunday, February 28, 2010 9:00 PM
|
|
|
|
 |
|
 |
Dear Mr. Gliznetsov,
I see in the BindableControl.cs file (id est Abstract Aga.Controls.Tree.NodeControls.BindableControl (: NodeControl), the first property, DataPropertyName set method says if the property name is null, change it to empty, then assign to value:
if (_propertyName == null)
_propertyName = string.Empty;
_propertyName = value;
But I can't imagine this being the intended code. Surely you meant:
_propertyName = value;
if (_propertyName == null)
_propertyName = String.Empty;
, right? Of course, the `lazy' way to do this would be
get { return (_propertyName ?? String.Empty); }
set { _propertyName = value; } Good work on the control! Really great work. Implementing it is a little difficult because of the spartan use of comments (that is no comments), but the code is clear enough to step through and figure out what has happened. I'm not using the designer, so that NodeControls was hard to find. I was thinking, "How the heck do I get the multiple columns, then once gotten, how the heck to I get my text in there!!?" But I'm getting it by looking VERY CLOSELY at the example. Perhaps I could help you comment some of the code?
In Christ,
Aaron Laws
modified on Tuesday, November 17, 2009 2:29 PM
|
|
|
|
 |
|
 |
How to disable the default tooltip of expandable node in asp.net 2.0
|
|
|
|
 |
|
 |
Hello,
I have a Problem I have 10.000 Nodes in the Treeview, each row has between 5 and 10 Subnodes. On Expanding the a Node it thakes up to 8 Seconds. I did some time measurement. the Most time is used in the Loop in CreateRowmap Method of TreeViewAdv class.
I did some Debugoutput to the Method and Submethods/Properties like ExpandedNodes and NextNode and noticed there is sometimes a pause of 10 milliseconds, where the process seams to be standing. The Pause occurs on different Codeparts. how more the loop goes forward, then moretime the pause occurs. Wenn Starting the loop the pause occurs every 50 rows, when processed more then 1.000 rows the pause ocours all 25 rows and so on.
has somebody any idea?
Kind Regards
|
|
|
|
 |
|
 |
hi Michael,
you might consider to use a TreeListView running in virtual mode, in order to view a huge amount of data. Please have a look at the VirtualModeTreeListView.
There is an example model that collapses a line with 65535 childlines in less than a second.
yetibrain
|
|
|
|
 |
|
 |
Can someone help Please.
How is it possible to have a Multi line Header for each columns for the tree view ?
regards
|
|
|
|
 |