Hi Joe
According to your reply I tried to test again.
I posted the follow statements:
-------------
//this.dataGridView1.DataSource = ds;
//this.dataGridView1.DataMember = "testTable";
BindingContext context = this.BindingContext;
CurrencyManager cm = context[ds, "testTable"] as CurrencyManager;
-------------
The issue has been reproduced.
The statement
------------
CurrencyManager cm = this.BindingContext[ds, "testTable"] as
CurrencyManager;
------------
It will take a long time to return when ds["testTable"] has 50k rows.
According to my research, I found that the actual reason causing this issue
is not "as CurrencyManager;" statement, but rather the
"BindingContext[dataSource, dataMemeber]" statement. It will take a long
time to return when the application is running under .Net 2.0 (this problem
isn't occur for .Net 1.1)
I think it could be an expected behavior in .net 2.0 due to additional
protection and checking code.
"this.BindContext[]" will do some checks on all the rows of DataTable when
DataTable hasn't been previously binding to any WinForm Controller (such as
DataGridView,ListBox,Combobox,Textbox..etc.).
Normally if we want to show the datatable in DatatGridView or Combobox, we
will set the databinding to our DataGridView or Combobox before we get the
"BindingContext".
Such as add the statement
"this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = "testTable";"
before statement
"CurrencyManager cm = this.BindingContext[ds, "testTable"] as
CurrencyManager;".
According to my test, it will not take a long tome to return.
If there is anything unclear or anything more that I can help you with,
please don't hesitate to post them in the community.
Wen Yuan
Microsoft Online Community Support
===============================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
===============================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)