Multiple Group Images

Jul 13, 2013 at 10:54 AM
I was wondering if it would be possible to have multiple group images is the group row. I would also want to have click event attached to each group image that allows us to get the rows belonging to the group.
Jul 13, 2013 at 3:21 PM
Edited Jul 14, 2013 at 1:17 PM
A ruff example of what I'm trying to achieve. I have added multiple images to every group as follows:

Changes in source code:

File: OutlookGrid.cs
//ADD PROPERTY
private List<Image> allGroupImages; 

public KryptonOutlookGrid()
        {
            InitializeComponent();

            // very important, this indicates that a new default row class is going to be used to fill the grid
            // in this case our custom OutlookGridRow class
            base.RowTemplate = new OutlookGridRow();
            this.groupCollection = new OutlookGridGroupCollection(null);
            internalRows = new List<OutlookGridRow>();
            allGroupImages = new List<Image>();
......
......
......
......
}
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public List<Image> AllGroupImages
        {
            get { return allGroupImages; }
            set { allGroupImages = value; }
        }
File: OutlookGridRow.cs
//Draw image group
                int imageoffset = 0;
                if (this.group.GroupImage != null)
                {
                    graphics.DrawImage(this.group.GroupImage, rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + group.Level * 15, rowBounds.Bottom - 22, 16, 16);
                    imageoffset = 18;
                }
//ADDED THE LINES BELOW TO DRAW LIST OF IMAGES TO GROUP ROW
               if (grid.AllGroupImages.Count != 0)
                {
                    foreach (Image icon in grid.AllGroupImages)
                    {
                        graphics.DrawImage(icon, rowHeadersWidth - grid.HorizontalScrollingOffset + 18 + imageoffset + group.Level * 15, rowBounds.Bottom - 22, 16, 16);
                        imageoffset += 18;
                    }
                }
Initialize as follows:
            OutlookGrid1.AllGroupImages.Add(Properties.Resources.flag_france);
            OutlookGrid1.AllGroupImages.Add(Properties.Resources.flag_germany);
            OutlookGrid1.AllGroupImages.Add(Properties.Resources.flag_france);
This adds a row of images to every group and it seems to work. Displays everything as should be.

My second question still remains though. How do I capture click events on each individual image. I would like a event to be thrown on each image click.

Image below:
Image
Coordinator
Jul 14, 2013 at 10:06 PM
Hi

Please take a look at source code changeset 28184, I've implemented the event GroupImageClick.
You can extend the function IsGroupImageHit in OutlookGridRow in a similar way you'done for displaying your other images.

However I wonder in which scenario you need to display several pictures for a group row. A group row is for one element and so one picture if any ?
The images you've added in OutlookGrid.cs will be for each group. Is this what you wanted to do ? If you would like to have multiple pictures per group you may check the following :
        /// <summary>
        /// Image associated to the group if any
        /// </summary>
        Image GroupImage { get; set; }
in IOutlookGridGroup.cs and OutlookGridGroup.cs and transform it in a list as you did.
Jul 15, 2013 at 11:32 AM
I'm want to group number of rows on which I perform different actions. Say I have a group row with three rows and I want to click one button to open a report on all three rows. With another button click open a dialog box that does something based on the three rows. And so on.
Jul 15, 2013 at 1:02 PM
I just finished implement the changes for the GroupImage click and custom group text. Working well. Thanx a lot for the help. Really appreciate it.
Marked as answer by Cocotteseb on 6/4/2014 at 11:30 AM