Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am trying to populating a datagrid using a dataset. Problem is that this dataset is getting populated from another thread. once the dataset is populated.. i'm doing a raiseevent to send the dataset teh event handler. in the handler i do a datagrid1.datasource=ds. if I leave it at that.. the datagrid is populated, but there is a plus sign in the grid..i click on that select the name of the table and there is my data. in the past when not using a thread I would put a datagrid1.datamemeber="tablename" and it would display the data in the grid without having to hit the plus key. does anyone know of a way around this. I want the grid to be displaying all the data without having to hit the plus key.

 

by the way.. when i try to add the tablename to the datamemeber, i get an error about "controls created on one thread cannot be parented to a control oon a different thread.

 

hopeing someone can help

thanks

shannon

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

got somethign working.. just not like I want..

  Dim MyDataSet As DataSet
   Dim MyDataAdapter As SqlDataAdapter

   Dim t1 As Thread
   Dim t1Start As New ThreadStart(AddressOf querydatabase)
   Dim callGrid As New MethodInvoker(AddressOf binddatatogrid)

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       launchit()
   End Sub

   Public Sub querydatabase()
       Dim o1 As New InvokerClass
       o1.Server = "(local)"
       MyDataSet = o1.Invokeit

       BeginInvoke(callGrid)

   End Sub
   Public Sub binddatatogrid()
       Me.DataGrid1.DataSource = MyDataSet
       Me.DataGrid1.DataMember = "authors"

   End Sub
   Public Sub launchit()
       t1 = New Thread(t1Start)
       t1.IsBackground = True
       t1.Name = "Test"
       t1.Start()
   End Sub

 

I'd still like to be able to pass a parm in to the query database and then use that parm on the o1.server=parm. but haven't got that figured out yet. I was going to try to make the querydatabase into a class and use a property.. does that sound like I'd be on the right track with that.

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...