aneeshvis Ответов: 1

Как я фильтрую данные из datagridview с помощью другого datagridview


I have an invoice form including datagridview1 for entering the item_name, quantity, rate and amount another hidden datagridview2 for showing filtered data from table 'item_details'. when I typing in this datagridview1's "item_name" column datagridview2 must show the data filtered from the database according to the typing.


Что я уже пробовал:

<pre>private void DataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
           // i = dataGridView1.CurrentRow.Index;
            if (dataGridView1.CurrentCell.ColumnIndex == 0)
            {
                TextBox product = e.Control as TextBox;
                result = product.Text;
                product.TextChanged += Product_TextChanged;
                product.Text = result;
            }
        }
		
		private void Product_TextChanged(object sender, EventArgs e)
        {
            dataGridView2.Visible = true;
            DataTable dt = pdal.searchitem(dataGridView1.Rows[i].Cells[0].Value.ToString());
            dataGridView2.DataSource = dt;
        }

Gerry Schmitz

Используйте пользовательский / пользовательский контроль ввода текста / инкрементный поиск "всплывающее окно", если вы хотите сохранить свое здравомыслие.

1 Ответов

Рейтинг:
0

Eddie98780

я думаю, что ваш пользовательский интерфейс не обновился ? каков ваш тип данных для dataGridView2 ? вы можете попробовать ObservableCollection в качестве типа данных.


aneeshvis

тип данных-строка