|
Hi,
i have a problem with collapsing node with custom control added as subitem on windows 7.
When collapsing node the subitem textbox remain displayed and not collapse.
Hi Marco
TextBox tb = new TextBox();
tb.Text = "test";
tb.BorderStyle = BorderStyle.FixedSingle;
ContainerListViewObject.ContainerListViewSubItem subItem = new ContainerListViewObject.ContainerListViewSubItem();
subItem.Control = tb;
node.SubItems.Add(sub);
|
|
|
|
|
more FAQ, manual - would be great
|
|
|
|
|
My development machine is not using Windows 7 so I have not had the luxury of sitting down and debuging this in detail. It seems that when we begin editing an item in a TreeListView on Windows 7 we trigger an exception in the Paint() method. This is part of the callstack:
Void Insert(System.Object, System.Object, Boolean) : Item has already been added. Key in dictionary: '{X=22,Y=38,Width=16,Height=16}' Key being added: '{X=22,Y=38,Width=16,Height=16}'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at WinControls.ListView.TreeListView._renderNodeRows(TreeListNode aNode, Graphics aGr, Rectangle Rect, Int32 aTotalRend)
at WinControls.ListView.TreeListView.OnDrawRows(Graphics aGr, Rectangle Rect)
at WinControls.ListView.ContainerListView.OnPaint(PaintEventArgs e)
I blindly modified _renderNodeRows so that it checks to see if the object exists in the hashtable before adding it like this:
<br />
If Not Me._NodeRowRects.Contains(completeItemBounds) Then<br />
Me._NodeRowRects.Add(completeItemBounds, aNode)<br />
End If<br />
But the bug still happens. Anyone else running into this?
|
|
|
|
|
OK, after sitting down on a machine with Windows 7 the code that I thought was causing the problem is not, it's actually the hash table for the _ImageRects that is trying to insert duplicate keys.
|
|
|
|
|
And it does the same for _PlusMinusRects....
I fixed it by testing if these rectangles exist in the hash tables, and if they do, don't add them. It seems to function fine.
|
|
|
|
|
1. I am unable to set font for separate node or subitem. Setting them 'natural' way has no effect - everything is showed same standard font. Same problem with colors: no reaction. How to do it properly? I need to set font.bold just to some specific subitems (not entire columns or 'rows'), and set specific colors.
2. Write to XML works but somehow extremely slowly... in my case unacceptably slowly. Is there any other way to save/load the tree? or how to make WriteXML faster?
2. My project shedule is pressing me hard and i am forced to ask author's, or someone else's (knowing this control better than me) direct help... who could help me? saulius.mikalauskas@ses.lt
Thanks beforehand
|
|
|
|
|
Is there a way to validate user input to a sub item?
If I handle the validating event, The user input is not present yet.
Handling the AfterEdit or Validated events doesn't allow me to cancel the the event if the user has inputted wrong values.
|
|
|
|
|
Hello,
I would need to validate user input in the subitem editing...
I need to force only numbers...
Please, someone knows how to do this?
|
|
|
|
|
This is the way I did it in the end:
1. Handle the BeforeEdit event of the TreeNode and save the original value
2. Handel the AfterEdit event of the TreeNode and validated the input there.
If the input is bad:
a. Save the input used by the user
b. Revert the value to the original value saved in step 1.
c. Call the TreeNode's BeginEdit event
d. Set the tree's EditedObject._EditBox.Text to the input saved in step 2a
If you're only looking to avoid numbers, you might be able to handle the OnKeyUp event and disallow numbers input.
|
|
|
|
|
Please can you send this code to my email??
I was trying to do this but i dont know why i cant make this work!
Thanks
|
|
|
|
|
I'm sorry but I can't send the code.
Have you tried to debug it? where exactly does your code fails?
|
|
|
|
|
I have issues trying to test it on Visual Studio 2010. Demo project (provided by author) is set up for .NET2.0 (works very fine), and trying to change it to anything else brings lots of errors.
To be short, how to make it work on .NET4?
Thank you!
|
|
|
|
|
Solved.
Just rebuild [source code] with required .NET version.
|
|
|
|
|
Hi,
i find your control very useful, but I need more columns with checkboxes.
Can you include the possibility to add not only text-columns but checkboxes too?
Thanks
T_uRRiCA_N
With the things I don't know, I could fill libraries
|
|
|
|
|
Hello,
Could you please tell how to double-click the column edge line to resize column width for fiting the maximal string width in this column? thank you.
|
|
|
|
|
The Tools.vb TruncateString function tries to work out the string that will fit in a given rectangle, it does this by measuring the string, if it does not fit it removes a char and measures again until it does. This is very slow for large strings, and I've seen it throw out of memory exceptions.
The following function converges on the result and is much faster.
I'm sure there should be a windows API to do this, but after a fair bit of looking nothing presented itself...
Let me know if there is a nice API that says the first x chars from this string will fit in this rect.
Public Shared Function TruncateString(ByVal aText As String, ByVal fontVal As Font, ByVal aWidth As Integer, ByVal aOffSet As Integer, ByVal aGr As Graphics) As String
Dim Sz As SizeF
' This function was very slow if large amounts of data were added
' This algorthum converges on teh solution, and is MUCH faster
Dim min As Integer = 0
Dim max As Integer = aText.Length
Dim testValue As Integer = Math.Min(200, max)
While (min < max)
Dim lastTestValue As Integer = testValue
Sz = aGr.MeasureString(aText.Substring(0, testValue), fontVal)
If Sz.Width > (aWidth - aOffSet) Then
If testValue = CInt(min + ((max - min) / 2)) Then
max = testValue - 1
End If
testValue = CInt(min + ((max - min) / 2))
ElseIf Sz.Width < (aWidth - aOffSet) Then
If testValue = CInt(min + ((max - min) / 2)) Then
min = testValue + 1
End If
testValue = CInt(min + ((max - min) / 2))
Else
' result
Return aText.Substring(0, testValue)
End If
End While
Return aText.Substring(0, testValue)
End Function
|
|
|
|
|
I don't know where the problem occurs but when i scroll using the mouse button or even clicking on the vertical scrollbar i have an error in my project using this control.
The message in Visual Studio is "NullReferenceException was undhandled". I try the tips for this kind of error i found in the VB troubleshoot database, but nothing work.
Each time the value in the controls are more then it's width, and that i use the vertical scrollbar i have an error.
If i resize the window in order to display all the lines in one single view everything seems to work fine.
Can someone help me understand and maybe correct this problem?
Best regards
|
|
|
|
|
I had the same problem. After several try and inspecting the code, I understood that RowHeight property shows unexpected behaviour. It works ok with default size of 16, you might have changed it to some other value. Keep it 16, it will work.
Thanks.
|
|
|
|
|
Yes i have the same Problem.
Default hight 16 works but all other crashs.
Its also the same in the sample.
I am not able to fix it. Usually anyone else?
|
|
|
|
|
hello,
try this fix, in the Function _findFirstNode in TreeListView.vb module, correct the bug
Return Me._findFirstNode(aStartingNode.NextSiblingNode, aStartingPoint - ((KidsCount + 1) * 16))
to:
Return Me._findFirstNode(aStartingNode.NextSiblingNode, aStartingPoint - ((KidsCount + 1) * Me.RowHeight))
in order to adapt for RowHeight property
|
|
|
|
|
This is very good programs.
Can you tell me how to find specific text.
Sadavarte U.S.
|
|
|
|
|
Is it possible to assign a specific image to a cell in the table rather than to the main tree portion?
Thanks
|
|
|
|
|
Hello,
i found a problem with myself.
I can´t found the "SelectedNode"-Property in the Treelistview.
The property doesn´t exist, and the "SelectedItems" haven´t got any property for "ParentNode" or something
else.
Now, how can i get the item? I wanted to remove the selected (sub-)node, but i can´t get it :-/
Thanks for help!
TBR
|
|
|
|
|
You have to cast the SelectedItem to a TreeListNode as the 'SelectedItems' property is inherited from the base class:
DirectCast(Me.SelectedItems(0), TreeListNode).ParentNode
|
|
|
|
|
Thanks,
i didn´t know i have to cast it
TBR
|
|
|
|