|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using the backgroundworker to populate a treeviewbackgroundworker I get an error "Action being performed on this control is being called from the wrong thread. Marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action (code to follow). What am I doing wrong. I moved the LoadWIP function to the backgroundworker DoWork method instead of calling the sub, but got the same problem. I am trying to get the background worker to load the treeview then I will have another background worker maintain the treeview by removing and adding nodes to the tree every minute. Any help would be appreciated. John Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork LoadWIP() 'load the steps ' LoadWIPParts(ds.Tables(0)) End Sub Private Sub LoadWIP() Dim ds As New DataSet Dim WIP As New localhost.WIP ds = WIP.GetTravelerByStation(8) Dim masterRow As DataRow masterRow = ds.Tables(0).Rows(0) 'Add the first row cell Dim masterNode As New TreeNode(masterRow("Station_Name").ToString()) TreeView1.Nodes.Add(masterNode)-------------> This line is giving the failure masterNode.ImageIndex = 6 masterNode.SelectedImageIndex = 6 'Go through the next rows and add the steps For Each childRow As DataRow In ds.Tables(0).Rows Dim childNode As New TreeNode("Step: " & childRow("Step").ToString()) masterNode.Nodes.Add(childNode) childNode.ImageIndex = 6 childNode.SelectedImageIndex = 6 Next 'load the steps LoadWIPParts(ds.Tables(0)) "john wright" <riley_wri***@hotmail.com> schrieb The message says what you're doing wrong and how to do it right.> I have my code done to populate a treeview, but when I move it to > the backgroundworker I get an error "Action being performed on this > control is being called from the wrong thread. Marshal to the > correct thread using Control.Invoke or Control.BeginInvoke to > perform this action (code to follow). What am I doing wrong. See also: http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconFreeThreadingWithFormsControls.asp http://msdn.microsoft.com/library/en-us/dnforms/html/winforms06112002.asp http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondevelopingmultithreadedwindowsformscontrol.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet09272002.asp Armin
VSTO 2005 - Read Range from excel
Create application to extract data from excel sheet How can we mail some file without mentioning the SMTP server addre Treeview population directly from MSAccess OOP / 3-Tier development questions VB.NET 2005 & XML writing custom event for minimise, restore and close buttons How to create a Service to Log Application Names Re: "Visual Web Developer does not support creating Web sites on a Macros too slow ! |
|||||||||||||||||||||||