davidegironi / advanceddatagridview

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

When filtered is all the data still there #111

Closed gadjet closed 1 year ago

gadjet commented 1 year ago

Hi, This is not a issue but more of a question. I have a graphic under a ADGV that reads throught some of the data in the ADGV, when I filter the columns in the ADGV I re-do the graphic generation but it doesn't change to reflect the filtered data.

Is there a way to hide the data that is hidden from view when filtered. To use the data I loop through the rows of the ADGV picking out values from certain columns and use in my Graphic (not an image) but the hidden data is still there although hidden from view in the ADGV.

Thanks

davidegironi commented 1 year ago

Hello @gadjet I'm not sure I've understand your question. If I've understand it, try this: set the Filter of your DataTable (.Filter) possibly cloning the ADGV datasource, getting the Filter string from ADGV.

gadjet commented 1 year ago

Let me try to explain a bit better than before, sorry. I load data from an excel file into a dataset which I then load into the ADGV, I then add some columns to the AGDV and add more data from a second excel file into the cells in the new columns matching criteria in other columns.

Once the ADGV is populated I take some dates (the added data from the second excel file) and I dra some empty labels with a background colour and the start and width is determined by some start and end dates (my version of a Gantt chart).

This all work well but I would like to be able to redraw the chart when the ADGV is filtered, which I do from the "FilterStringChanged" event but the chart stays the same, I'm assuming thats because even though some of the data has now been filtered out it is still there programatically so that when I loop through the rows and cells it still picks up the hidden data.

I was wondering if my assumption is correct and if so is there anything I can do about it.

Thanks for replying so quickly to my question.

davidegironi commented 1 year ago

The FilterStringChanged run before the underline BindingSource has been filtered, this could be the reason why you don't get the change. Have you try using a single bindingsource?

gadjet commented 1 year ago

Sorry but I'm not that knowledgeable about these sorts of things. My datasource for the ADGV is an excel file and the only source of the data is the ADGV and I get the data by looping through the rows and cells, I wouldn't know how or what to bind 😕

davidegironi commented 1 year ago

Take as reference the sample project. There I've used a bindingsource. I close this as issue.