Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
Group By Image column
posted

Thanks to everyone who helped last time.

I have an image column that represents a row's status (one of three different statuses).  When the user groups by the image column, I get multiple group by rows with the same status.  The rows seem to be randomly distributed in the different groups.

For example, say I have 300 rows, 100 in each status.  When I group by the image column that represents the status, I'll get 18 different groups (random # of groups).  8 of them might be new, 6 halfway, and 4 completed status.  In each of the status groups there might be from 2-20 rows.

The Images are statically assigned using a ResourceManager in VS 2005.  I'm using a double-checked locking pattern to try to ensure there is only 1 image of each status type created, but that did not seem to make a difference.

Any ideas on how to force the statuses to group together?

Should I change back to a text status column and then use a DrawFilter to replace that with an image icon?  Can I even do that?

Thanks!

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    It's hard to be sure without more information, but my guess is that the problem is with the sorting of the column.

    When the grid is grouped, the column has to be sorted first. Then the grid just loops through the rows in order to determine which ones belong to the same group.

    Bitmaps are not IComparable, so there's no way the grid can sort them. And if they are not sorting, then it would result in repeated groups just like you describe. Only rows that happened to have the same value and happened to be adjacent would be grouped.

    The solution to this is to use a SortComparer on the image column that compares the rows based on their status in some more meaningful way, rather than comparing the two images.You images are probably based on the value in some other (perhaps hidden) column in the band, so all you have to do is take the cells passed into the Compare method, get the row, get the status cell's value and return the Compare of that value.

Children
No Data