vb.net - Filling DataGridView from BackgroundWorker -


This is the case:
I have a DataGridView form and when I started I should start filling the form DGV with the backgroundwalker .

  Private Sub FirstSub () adoconn () Me.Enabled = false bw.RunWorkerAsync () Me.Enabled = True End Sub Personal Sub-bw_DoWork (as the object, in the form of e DoWorkEventArgs ) BW handles. DoWork Retarder works as BackgroundWorker = CTYPE (Sender, BackgroundWorker) as DataGridView1.InvokeRequired Then for '// VB 10 you can use an anonymous sub-DataGridView1.Invoke (sub) (bw_DoWork (sender, e)) or else DataBaseLayer. Try FillDTwithSP ("ArticlesSelect", ds_Tables.Articles) Me.DataGridView1.DataSource = ds_Tables.Articles Me.DataGridView1.ClearSelection () Pre-Exception As an Exception Try the other end from the MsgBox (ex.ToString) end, then End Sub   

After Carlos giving me an example of what I should do, I did this, however Now I have a problem that when I do not even get place in BrakePoint bw_DoWork sub

  private sub FirstSub () adoconn () Me.Enabled = false bw. WorkerReportsProgress = True AddHandler bw.DoWork, AddressOf bw_DoWork AddHandler bw.ProgressChanged, AddressOf bw_ProgressChanged Me.Enabled = True End Sub Private Sub bw_ProgressChanged (Sub-send as object, changing progress event by changing progression) DataBaseLayer.FillDTwithSP ("Articles Select ", ds_Tables.Articles). Me.DataGridView1.DataSource = ds_Tables.Articles Me.DataGridView1.ClearSelection () Exception as Exempt MsgBox (ex.ToString) End End Sub Private Sub-bw_DoWork (as the object, in the form of e DoWorkEventArgs) Dim Worker BackgroundWorker = CTYPE (Sender, BackgroundWorker) bw.ReportProgress (Sender, e) Try  as End Sub  

Therefore, my desired thing is filled with my DataTable And the DataGridView result is set to as long as the DT is disabled by all controls on the form. The thing is that when I load this form then all this becomes free again and un-free when it is all right, so there is no effect of BackgroundWorker .

If you need someone else please feel free to tell me the information or code part so that I can solve this problem.

thanks,
yes

To review some of this After the thread I can tell a few things which I see.

  1. You are trying to set your source in progress changing events , if you have a representative and use it properly.
  2. The progressed event should not be used to only report progress, change the UI or any control.
  3. There is no need to add handlers because they have already taken care of them.

    I'm not sure where your calling first user method, I will accept it from a load event or maybe click on the event, which does not matter anyway Below are the changes I have made and should be good for you. You can also check out my other answers and, for both of you to look for reference and what needs to be replaced, both are great.

      Representative sub setDataTable (as inVal DT DataTable) 'Your Representative .. Private Sub FirstSub () adoconn () Me.Enabled = false bw.RunWorkerAsync () Me.Enabled = True End Sub 'method that fills DataGridView1 private sub AddSource (byVal DT as DataTable) if Me.DataGridView1.InvokeRequired then' invoke if necessary ... dim d New setDataTable (AddressOf AddSource) Me.Invoke (d, new object) {DT}) Otherwise, no calls are needed ... Me.DataGridView1.DataSource = Me.DataGridView1.ClearSelection (DT) End End Sub Private Sub-bw_DoWork (As in this object, E. System.ComponentModel. DoWorkEvent Args manages as bw.DoWork (bw.CancellationPending) then DataBaseLayer.FillDTwithSP ("ArticlesSelect", ds_Tables.Articles) AddSource (ds_Tables.Articles) ElseIf (bw.CancellationPending) E.Cankel = True End End And Sub   

    Tell me how it works for you and I checked you two other links. Apart from this, on another note, you can change the call to DoWork to pass DataTable in your method AddSource and call it ...

    MrCodexer

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -