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
610
GroupBy row description for Bitmap
posted

We have a column that has a bitmap "icon" in it. When grouping by that column, we get the bitmap with a text description of "System.Drawing.Bitmap". What would be the best way to replace that with something custom?

GroupBy with text description of "System.Drawing.Bitmap"

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    Grouping by an image is not really possible because two rows with the "same" image actually have two different instances, i.e., Image.Equals will return false even though they contain the same graphical data, because they are two different instances.

    There are a few different ways to handle this, the easiest of which is probably to persist an integer or string that identifies the image rather than the image itself, and add an unbound column for the image data. You could use InitializeRow to read the persisted number/string, use that to determine what image to display, assign that image to the unbound column, and hide the column that contains the persisted data. This approach has the benefit of not persisting redundant image data, i.e., if you have 100 records with the same image, you don't want to keep 100 copies of the image data, just something that identifies the image.

    To group by an image, you would have implement IGroupByEvaluator (no big deal, only two methods) and assign the implementation to the image column's GroupByEvaluator property. Your implementation would look at the column that holds the persisted number/string, decide which image that corresponds to, and group according to that.

    If you need us to provide code samples for any of this just repost and someone will help you out.

Children
No Data