Example #1
0
        //private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        //{

        //}

        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            var anaekran = db.sp_anaekran4();

            dataGridView1.DataSource = anaekran;
            this.dataGridView1.Columns["UrunID"].Visible = false;
            DataGridViewRowCollection copyRows = new DataGridViewRowCollection(new DataGridView());

            copyRows = dataGridView1.Rows;
            CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dataGridView1.DataSource];

            currencyManager1.SuspendBinding();
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    return;
                }
                else if (comboBox1.SelectedIndex == 1)
                {
                    if (row.Cells[1].Value.ToString() == "Yiyecek")
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }

                else if (comboBox1.SelectedIndex == 2)
                {
                    if (row.Cells[1].Value.ToString() == "Sigara")
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }
                else if (comboBox1.SelectedIndex == 3)
                {
                    if (row.Cells[1].Value.ToString() == "Alkol")
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }

                else if (comboBox1.SelectedIndex == 4)
                {
                    if (row.Cells[1].Value.ToString() == "Temizlik")
                    {
                        row.Visible = true;
                    }
                    else
                    {
                        row.Visible = false;
                    }
                }
            }
            currencyManager1.ResumeBinding();
        }