Closed kirsan31 closed 3 years ago
Hello, that's sounds good, but this project is used with BindingSource, changing this behaviour will cause some refactoring in project that use this library. You can do this by attaching an event to the FilterStringChanged and SortStringChanged. Don't forget to set e.Cancel to skip the Filer and Sorting internal mechanism. Take a look at advancedDataGridView_main_FilterStringChanged and advancedDataGridView_main_SortStringChanged in the sample project as example.
Hello, that's sounds good, but this project is used with BindingSource, changing this behaviour will cause some refactoring in project that use this library. You can do this by attaching an event to the FilterStringChanged and SortStringChanged. Don't forget to set e.Cancel to skip the Filer and Sorting internal mechanism. Take a look at advancedDataGridView_main_FilterStringChanged and advancedDataGridView_main_SortStringChanged in the sample project as example.
I think you didn't get it. This is addition (not replace) and will not require refactoring because for now (as your said above) if you use other datasource beside BindingSource you need to use FilterStringChanged + SortStringChanged and set e.Cancel to true. So new code will never be called, becose it inside
if (filterEventArgs.Cancel == false)
{
}
It's just strange that of the two standard classes (DataView
, BindingSource
) that implement IBindingListView
advanceddatagridview out of the box can work only with BindingSource
.
But it's your decision any way. Thank you once more.
Now I get this. You mean something like this? for TriggerFilterStringChanged:
//...
if (filterEventArgs.Cancel == false)
{
if (this.DataSource is BindingSource bindingsource)
{
bindingsource.Filter = filterEventArgs.FilterString;
}
else if (this.DataSource is DataView dataview)
{
dataview.RowFilter = filterEventArgs.FilterString;
}
else if (this.DataSource is DataTable datatable)
{
if (datatable.DefaultView != null)
datatable.DefaultView.RowFilter = filterEventArgs.FilterString;
}
}
//...
Exactly. All my code from 1 post must replace code in this condition:
if (filterEventArgs.Cancel == false)
{
}
Sorry for misleading.
Hello, I'm posting your code update in the next deploy, if you want a preview download it from here: https://github.com/davidegironi/advanceddatagridview/issues/68#issuecomment-868566190
Hi. I was trying to set
DataTable
orDataView
directly asDataSource
. And this lead to filtering and sorting are stop working automatically. What do you think about addingDataTable
andDataView
to supported DataSources (even defaultDataGridView
are support them)? Something like this: TriggerFilterStringChanged:TriggerSortStringChanged:
This will allow to skip using excess
BindingSource
or manual sorting. Thanks.