필터를 DataGrid에 적용하는 코드를 상속했지만 필터가 작동하지만 DataGrid에 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