c# - column header text changes after change DataSource? -
when change datasource of datagridview datatable don't have rows, , after change datasource datatable contains rows, header text changes , properties width...
try using bindingsource
control between datagridview
, datatable
. bindingsource
control has useful property called filter
filter out unwanted rows without creating new datatable
object or otherwise affecting structure of underlying datatable
, datagridview's headers not affected.
you can either manually through code or drop instance of bindingsource in designer. code this:
bindingsource bs = new bindingsource(); bs.datasource = yourdatatable; yourgridview.datasource = bs;
then can filter out results doing:
bs.filter = "some_column = 'some_value'";
Comments
Post a Comment