473,326 Members | 2,173 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,326 software developers and data experts.

selectednode in Treeview lost when accessed by spawned Thread

Hello,

I am trying to spawn a sunroutine in a worker thread for populating a
trreeview. I set the selectednode and then start the thread. However, the
thread errors because the selectednode was found to equal "Nothing".

Is there some kind of trick to get the threaded subroutine to see the
selectednode to process?

Thank you inadvance for any assistance.

Dean.
May 30 '06 #1
1 1276
Dean,

You can't access a form or control from a thread other than the main UI
thread. That doesn't mean you can't take advantage of threads though.
What I would do is use my worker thread to retrieve the list of items
from the database or whatever and place them in some type of collection
and then call Control.BeginInvoke at the end of the worker thread to
marshal the execution of a delegate onto the UI thread. That delegate
would build the treeview from the collection you just populated.

The following is an excellent introduction to using threads in Windows
forms.

<http://www.yoda.arachsys.com/csharp/threads/winforms.shtml>

Brian

Dean Hinson wrote:
Hello,

I am trying to spawn a sunroutine in a worker thread for populating a
trreeview. I set the selectednode and then start the thread. However, the
thread errors because the selectednode was found to equal "Nothing".

Is there some kind of trick to get the threaded subroutine to see the
selectednode to process?

Thank you inadvance for any assistance.

Dean.


May 31 '06 #2

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

Similar topics

4
by: David Elliott | last post by:
Hi, I have a Windows Explorer-like treeview that displays directories. After a cut/paste operation, I want the treeview to display the folder where the paste happened. But, I'm running into a...
1
by: jyoti ranjan | last post by:
i have a ie webcontrols treeview in my application. by default treeview is selecting the first node as selected index. i don't want a default selectednode. how can i get that one . can any body pls...
1
by: Progalex | last post by:
Hi, I have a treeview, called Treeview1 with one father node and some children nodes. Number of children nodes can change since every child node is a file name that the user add through an Open...
0
by: Bobby Owens | last post by:
Hi, I'm current having a problem with the treeview control and multi threading. The treeview is on a form. A request is then sent to a server using IP for the data. The data arrives in an event...
0
by: Jared | last post by:
I am using a TreeView with data stored in a database and have been trying to store a node index over a postback and re-select the node without using javascript. I couldn't find anything in these...
8
by: Jerry | last post by:
Hello, I am able to GET the selected node with my code. I would however like to SET any node with code. Something like me.treeview.selectednode="First" But this doesn't work. I can't find...
0
by: stacy | last post by:
My asp.net Web application is written in VB, using VS 2005 with Framework 2.0 I am having trouble with the SelectedNode element. The TreeView is built programmatically and looks like this: -...
0
by: bsturg21 | last post by:
Hello, I have an app that has a custom treeview which inherits the base treeview class and I am having a problem with the way the treeview is being redrawn. Each node in the treeview represents a...
1
by: Spam Catcher | last post by:
When I set the SelectedNode programmatically, how come the AfteSelect doesn't fire? Other controls (i.e. combobox) I believe do fire the SelectedIndexChanged when you programmatically update the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.