davidegironi / advanceddatagridview

A .NET WinForms DataGridView with advanced capabilities
392 stars 123 forks source link

automatically disable Filter/Sort for unbound Columns OR let them sort/filter by ItemValue.ToString #103

Closed TraglDotNet closed 1 year ago

TraglDotNet commented 1 year ago

Hello.

I'd like using the AdvancedDataGridView in my little Project. But now i'm struggeling with the following constellation:

ADGV With typed DataTable As DataSource: Filtering and Sorting works nicely. Added some unbound Columns and Filling them with some Values during the RowPrepaint-Event.

Filtering and Sorting for those Columns ends in Crashing. Would it be possible to turn filtering/sorting automatically off? My actual Workaround for this: `

Friend Sub DisableFilterAndSortForUnboundColumns(aDgv As AdvancedDataGridView) aDgv.ColumnsX.Where(Function(x) Not x.IsDataBound).ForEach(Sub(col) aDgv.DisableFilterAndSort(col)) End Sub ` OR (i think the better way): Would it be possible to Sort the unbound-column-items Value.Tostring?
davidegironi commented 1 year ago

Hello, I don't fully understand what you are trying to do. If you can build up a stand-alone sample project I can take a look at it as soon as I've time do spend on.

TraglDotNet commented 1 year ago

Hi,

here's a small Test-Project which shows the "Problem". As the Screenshot shows, the green section can be filtered (bound to DataTable), the red section shows an Error (not bound). The unbound-Columns were made in Designer-Mode, the values are created from the RowPrepaint-EventArgs. The needed xml-file should be created until Debugging so you can easy fill just 2 rows with ValueText, Value1 and Value 2 - both of the unbound-fields are filled automatically then.

I also added my small extension to turn filtering for unbound columns on or off. I hope it's unterstandable now :-)

aDgvTest01.zip

Screenshot 2023-03-11 200023 Screenshot 2023-03-11 200243

davidegironi commented 1 year ago

Thanks, now I get what you mean. Mixed column mode does not work. What I suggest you is to add a fields to the DataSet loaded, or the XML file. Than work on that field. Otherwise you have to disable the filtering and sorting like you are doing.