0

Respected peers,

I am having a major problem on a project I am working on and need some help please.

Overview: I have one form (frmStart) with a datagridview (Datagridview1). In frmstart I have placed a binding source (bs1). This one form accepts the results of two differing queries (q1 and q2).

The first time I run a query (q1) the binding source loads exceptionally fast. I use the following to attach:

frmStart.bs1.DataSource = frmStart.ds.Tables("Data1").DefaultView

I can continue to load this each and every time efficiently. If however, I try to run the second query (q2) and apply it to the form OR run the second then try to go back to q1, the program hangs on the following line and takes 10 times longer to load than the original:

Me.bs1.DataSource = ds.Tables("Data2").DefaultView

I know it has something to do with changing the source table, because it also happens in reverse. My question is what am I not doing that is causing this problem. Once I finish with one report I clear my page using the following, but have proven that this plays no part either:

Me.bs1.DataSource = Nothing
Me.bs1.RemoveFilter()

I have tested and tested and can determine that the filter plays no part, merely the changing of the datasource table. Does anyone have a solution they could throw me, or just a point in the right direction? What am I doing wrong, or not doing at all?

When changing a binding source, is there a correct procedure?

Thanks in advance.

Brett Hyland
  • 11
  • 1
  • 5

1 Answers1

0

Jumped into the same problem, this worked for me:

You should unset the RaiseListChangedEvents property on the BindingSource before you do a big set of changes on the BindingSource and reset if after you're done. Then you can use ResetBindings to refresh the bound controls.

From: Using BindingSource is very slow?

Community
  • 1
  • 1