DataTable的过滤器的三种做法

前两种是公司老大平时用的

dataTable.select和dataview.filter

后面这种是用的

CurrencyManager cm = (CurrencyManager)BindingContext[ConditionGridView.DataSource];
                int rowCount = cm.Count;

                for (int row = 0; row < rowCount; ++row)
                {
                    DataGridViewRow dgvr = ConditionGridView.Rows[row];
                    int tempi = int.Parse(dgvr.Cells[1].Value.ToString());
                    DataGridViewRow dgvr2 = ConditionGridView.Rows[row + 1];
                    int tempi2 = int.Parse(dgvr2.Cells[1].Value.ToString());
                    DataTable dt;
                   
                    if (currentExp > tempi && currentExp < tempi2)
                    {
                        cm.SuspendBinding();//这是挂起数据的绑定,是必要有的,
                        dgvr.Visible = true;
                        dgvr2.Visible = true;
                        num = 1;

                        tempi3 = int.Parse(dgvr.Cells[0].Value.ToString());
                    }
                    else
                    {
                        cm.SuspendBinding();
                        if (num == 1)
                        {

                            dgvr2.Visible = false;
                            num = 0; 
                        }
                        else if (num == 0)
                        {
                            dgvr.Visible = false;
                            dgvr2.Visible = false;

                        }


                    } 

你可能感兴趣的:(NET架构,c#)