フィルタはデータグリッドに適用されるコードを継承していますが、フィルタは機能しますが、データグリッドに500以上の行がある場合、フィルタは機能しますが(500以上でハングアップし、100行でうまく動作します)、フィルタは基本的に「お支払いいただいた皆を見せてください」または「X国の皆さんに見せてください」C#なぜこのループは遅いのですか?
フィルタに一致する行のリスト(filtered filtered below)は即座に作成されます。
if (comboBoxFilterCondition.Text == "Contains")
{
strSearchFilter += string.IsNullOrEmpty(txtFilterValue.Text) ? " IS NULL" : " LIKE '%" + txtFilterValue.Text + "%'";
}
FilterRows(strSearchFilter);
// ....
private void FilterRows(string strSearchFilter)
{
DataTable table = dataGridView1.DataSource as DataTable;
if (table != null)
{
List<DataRow> filteredRows = new List<DataRow>(table.Select(strSearchFilter)); //<----Very quick to here
CurrencyManager cm = (CurrencyManager)BindingContext[dataGridView1.DataSource];
cm.SuspendBinding();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Visible = filteredRows.Contains(((DataRowView)row.DataBoundItem).Row); //<---Stuck here
}
cm.ResumeBinding(); //<----------Doesn't arrive here
// ..... }
任意のアイデア? ありがとうございました
ハッシュセットは.net 3.5ですか?私は.net 2.0を使用しています。ありがとうございます –
ああ、それは.NET 3.5のものです – AgileJon