DataGridView with virtual mode sorting

0
0

Hi!
I have some trouble trying to sort a DGV with the options “Virtual Mode”.

I have download a sample from the forum and i’m trying to use sort mode on the first column.

Events like “SortCompare” e “SortMode” are not fired, it’s correct ?

I attacched the modify porject.

Thanks for support.

  • You must to post comments
0
0

Hi Simone,

Just wanted to know if everything is fine.
If not just let us know.

Best regards,
Alaa

  • You must to post comments
0
0

Ciao Simone, in virtual mode the grid cannot move the rows since they don’t exist. You should set the Column.SortMode to Programmatic and in ColumnHeaderMouseClick sort your data source, being virtual could be anything. You can change the sort glyph isetting Column.HeaderCell.SortGlyphDirection.

However, I see a shortcoming in the implementation that we can make better. When in virtual and SortMode is Automatic, the datagrid still sets the glyphs mode but doesn’t update the SortedColumn or SortDirection properties since they are used only when it can sort the data source itself. So you’d have to keep track of the sort order and sort column.

You may also override this:

 protected virtual object OnWebDataRead(int firstIndex, int lastIndex, ListSortDirection sortDirection, int sortIndex)

 

That works if you keep SortMode to Automatic. You will get this call with the updated SortDirection and the index of the column to sort. This lets you change the order of your data.

HTH

 

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.