473,396 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

strange problem adding child node to a parent node

Ok, so I'm absoultely positive this was working last night, but today I'm
getting this error in my program when I try to add a child node to a parent
node of a tree...

The error says:

Message: The action being performed on this control is being called from the
wrong thread. You must marshal to the correct thread using Control.Invoke or
Control.BeginInvoke to perform this action.
Stack Trace: at System.Windows.Forms.TreeNode.Realize()
at System.Windows.Forms.TreeNodeCollection.Add(TreeNo de node)
at test.MyNode.AddChild(MyBaseNode node) in ...

So what does this all mean? By the time this error occurs it has already
gone through this same method adding about 30 nodes (confirmed by output)....
Nov 16 '05 #1
3 3144
Hi,

The error message says it all - you are most likely accessing the TreeView
control from a worker thread, which is prohibited.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Ok, so I'm absoultely positive this was working last night, but today I'm
getting this error in my program when I try to add a child node to a
parent
node of a tree...

The error says:

Message: The action being performed on this control is being called from
the
wrong thread. You must marshal to the correct thread using Control.Invoke
or
Control.BeginInvoke to perform this action.
Stack Trace: at System.Windows.Forms.TreeNode.Realize()
at System.Windows.Forms.TreeNodeCollection.Add(TreeNo de node)
at test.MyNode.AddChild(MyBaseNode node) in ...

So what does this all mean? By the time this error occurs it has already
gone through this same method adding about 30 nodes (confirmed by
output)....


Nov 16 '05 #2
Thanks for your reply! Well, I'm not exactly accessing a Treeview from a
worker thread, what I'm doing is having a worker thread create a root
TreeNode and then add children to it, then later when everything is done and
I'm ready to display this to the UI , I create the dialog, the TreeView and
just add this root node.

Do I have to take the extreme step of creating a non-tree-specific structure
in this worker thread, then once I'm ready for the UI to convert it into a
tree?

"Dmitriy Lapshin [C# / .NET MVP]" wrote:
Hi,

The error message says it all - you are most likely accessing the TreeView
control from a worker thread, which is prohibited.

Nov 16 '05 #3
I think you can create the hierarchy of TreeNodes on a worker thread, but
once the hierarchy is ready, the rest should happen on the UI thread.
In particular, make sure you assign the root node to the treeview on the UI
thread.

If you still get the exception, you will indeed have to create a parallel
hierarchical structure on the worker thread and to convert it to tree nodes
on the UI thread.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Thanks for your reply! Well, I'm not exactly accessing a Treeview from a
worker thread, what I'm doing is having a worker thread create a root
TreeNode and then add children to it, then later when everything is done
and
I'm ready to display this to the UI , I create the dialog, the TreeView
and
just add this root node.

Do I have to take the extreme step of creating a non-tree-specific
structure
in this worker thread, then once I'm ready for the UI to convert it into a
tree?

"Dmitriy Lapshin [C# / .NET MVP]" wrote:
Hi,

The error message says it all - you are most likely accessing the
TreeView
control from a worker thread, which is prohibited.


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rob.guitar.rob | last post by:
Hello, My last few posts have been revolving aroung the same problem, and I still cant solve it and I would be really appreciate if anyone could spot a problem. a section of my XML goes like...
2
by: Bjorn | last post by:
Hi all, Can't seem to figure out how to retrieve the text of a node with multiple child nodes (and I just want the text of the parent, not the InnerText or InnerXML that comes with it). My...
3
by: Brian Henry | last post by:
If i already have a tree view created, and want to add another new node to it, how would i do so? Is there a way to throught tags or anything? like i have this RootNode | +-- Child 1 +--...
7
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
5
by: B-Dog | last post by:
I want to be able to detect if a user has selected a parent or child node in a treeview and depending on which is clicked act accordingly based on the tag. I can get the values but don't know if...
2
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
4
by: patrizio.trinchini | last post by:
Hi all, I'm new to XSLT and maybe my problem have a very trivial answer, but I need an expert that point me in the right direction. What I would obtain is to remove all the elements that have a...
0
by: romcab | last post by:
Hello expert, I would like to ask how can I add a parent node and child node simultaneously. I try this code; //create parent node XmlElement ^elem =...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + How can I specify the parent when adding a new node...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.