Maintain DataGridView format when doing C # filter


I happen to have a DatagridView with the following format (ver Imagen) (Orange -> CheckBox and white disabled -> CheckBox activated, it turns out that I want to filter this DataGridView and I do it like this:

public void filtrarPorClave()
    DataView dv = (DataTable)dgvExistencia.DataSource.DefaultView;
    dv.RowFilter = string.Format("CLAVE_ART LIKE '%{0}%'", TextBox1.Text);

The filter does me correctly, but does it take away the format, some form of maintaining the format when filtering the data?

I appreciate any suggestions.

asked by Silvestre Silva 18.10.2018 в 17:12

1 answer


You have 2 ways to solve this problem.

1- Set it from the properties of the datagridview

2- Instead of loading your application, you make a method that has that function and then call it every time you upload or filter the dgv

I hope you get the answer.


answered by 03.01.2019 в 21:56