コード例 #1
0
        /// <summary>
        /// Remove filter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Things get a tad complicated here in regards to keeping the current row
        /// as we need to make sure the row still exists
        /// </remarks>
        private void cmdRemoveFilter_Click(object sender, EventArgs e)
        {
            Customer tempCustomer = null;

            if (bsCustomers.CurrentRowIsValid())
            {
                tempCustomer = bsCustomers.Customer();
            }

            Customers customers = new Customers(true);

            blCustomers = new SortableBindingList <Customer>(customers.DataSource);

            bsCustomers.DataSource   = blCustomers;
            dataGridView1.DataSource = bsCustomers;

            if (tempCustomer.IsValid())
            {
                currentCustomer = blCustomers.Where(cust => cust.CustomerIdentifier == tempCustomer.CustomerIdentifier).FirstOrDefault();
                if (currentCustomer.IsValid())
                {
                    bsCustomers.Position = blCustomers.IndexOf(currentCustomer);
                }
            }
        }