Amazing invisible TreeNode

  • Thread starter Thread starter Marius Horak
  • Start date Start date
M

Marius Horak

I have a custom control with two treeviews.
The idea is the if a user double clicks on a node in TreeView A a new
node is added to TreeView B. But when the first node is added it does
not show on in TreeView B, Nodes.Count is 1. Nothing helps, nor Refresh
no DoEvents. When a next node is added both nodes will appear. Next, if
I remove the second node, both nodes will vanish, Nodes.Count is 1.

Amazing what we can do with DotNet and Windows.

MH
 
The TreeNode object of TreeView A went to TreeView B? Is that correct?
If so, have you called the Remove method? Be aware that a tree node can only
be part of one treeview and only have one parent. Ideally the parent and the
tree node and the parent should be in the same TreeView ;-)

Robert
 
be part of one treeview and only have one parent. Ideally the parent and
the
tree node and the parent should be in the same TreeView ;-)

One parent to much of course.
 
Robert said:
The TreeNode object of TreeView A went to TreeView B? Is that correct?
If so, have you called the Remove method? Be aware that a tree node
can only be part of one treeview and only have one parent. Ideally
the parent and the tree node and the parent should be in the same
TreeView ;-)

I will make an exception and I will be polite to you this time.
Did you notice "a new node is added to TreeView B" in my post?

MH
 
Stupid M$$$$$$ programmers?

Before allowing the user to add new nodes I add to TreeViewB earlier
selected items (from database). It looks like this.

TreeViewB.Nodes.Clear;
TreeViewB.BeginUpdate();
foreach (item in ListOfItems)
TreeViewB.Nodes.Add(new TreeNode(item.Title));
TreeViewB.EndUpdate();

The problem is that if the ListOfItems is empty nothing will be added
and thanks to M$$$$$$ programmers(?) the TreeView is probably still in
BeginUpdate state. Adding new node will add the node but as the
TreeView is still in BeginUpdate state nothing will be shown on the
screen.

I can bet that inside EndUpdate M$ checks the number of nodes and exits
from it without changing the status.

I wish all M$ staff was driving cars with only 1% of faults they put
into M$ software. I lost 4 hours tracing this problem. Shame on you M$.



MH
 
I will make an exception and I will be polite to you this time.
Did you notice "a new node is added to TreeView B" in my post?

Sorry for that. How could I miss that. Such a shame. I apologize for that.
Luckily you have made an exception. I don't want to know what you will do
next time to me. Puh...
 
My suggestion: use another language that does not come from Microsoft. Then
you will be much happier.
 
Robert said:
My suggestion: use another language that does not come from
Microsoft. Then you will be much happier.

Nothing wrong with C#. Just people behind its implementation.

For unknown reason software companies managed to convince every
government that they can produce faulty software, take money, use users
as guinea pigs for free testing and charge for fixing bugs.
Pharmaceutics or motor companies would be sued for this for he last
penny.
Private people would be charged with fraud.

MH
 
You are right of course. However, two notes:
1.I think it is not just the software industry that produce half ready
products. Nearly every company wants to make maximum profit - regardless if
it is ethically correct or not. But some can do this more effective than
others. And even the car industry does it: we can recognize more and more
car recalls. Since they get less tested. No money for that.
2. No one has to use MS products. There are alternatives. I don't have to
mention which ones.

Robert
 
The problem is that if the ListOfItems is empty nothing will be added
and thanks to M$$$$$$ programmers(?) the TreeView is probably still in
BeginUpdate state. Adding new node will add the node but as the
TreeView is still in BeginUpdate state nothing will be shown on the
screen.

I can bet that inside EndUpdate M$ checks the number of nodes and exits
from it without changing the status.

You havn't called BeginUpdate twice and EndUpdate only once somewhere? I
just had a look and the calls to BeginUpdate and EndUpdate must be
balenced, and it does not take into account whether any changes have
been made or not.
 
Back
Top