Hi,
Is there a way that the encompassing border for a group of rows sharing the same merge cell data be drawn differently?
To explain we have rows of data representing bookings. To make things easier for the user the cell data for the day of the week is set as a merge cell. This means that if there are three bookings for Monday then the user sees once nice Merged cell block for Monday and the three records. There would then be more data records for each day in the month etc..
This is very nice, however, users have asked is it possible to draw a thick line border around the whole 3 row blocks of data (The rows that share the same merge cell value) as it is difficult to distinguish between the day breaks...
Any thoughts would be appreciated. Ta
Tbh you could ignore the _factory bit all it does is render the background of a cell similar to an appointment schedule view. But yes you could ignore that bit. As for :
For one thing, each ColScrollRegion has it's own set of UIElements, so you should not need to loop through them
I'm open to any ideas - I'm free to admit it is a bit dirty atm, just the documentation is a bit sketchy or more likely this is a bit more advanced than the usual.
It's really hard to tell from a code snippet, but you do seem to be looping a lot more than I would think would be neccessary, For one thing, each ColScrollRegion has it's own set of UIElements, so you should not need to loop through them.
I also don't know what you _factory class is doing or why you are handling AfterDrawBackColor.
Thanks IGDrewS it prompted me with an alternative process which works. However, the performance suxxx big time. If the folks at Infragistics could help in pointing out anything obvious I.e. you shouldnt be doing it that way or anything it would be appreciated. I am guessing that I should not be processing the entire contents in one hit either way, any details would be good.
If you are wondering the performance hit is evident when you try and scroll up or down - it is significantly slower.
Here is my code in full.
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is EmbeddableUIElementBase) return Infragistics.Win.DrawPhase.AfterDrawBackColor; else if (drawParams.Element is RowColRegionIntersectionUIElement) return Infragistics.Win.DrawPhase.AfterDrawElement; else return Infragistics.Win.DrawPhase.None; } public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // This part of the code draws a nice background in one of my cells if (drawParams.Element is EmbeddableUIElementBase && drawParams.DrawPhase == Infragistics.Win.DrawPhase.AfterDrawBackColor) { CellUIElement oCellUIElement = (CellUIElement)drawParams.Element.GetAncestor(typeof(CellUIElement)); if (oCellUIElement != null && oCellUIElement.Cell != null) { UltraGridCell oCell = oCellUIElement.Cell; if (oCell == null || oCell.Column.Key != _CellColumn) return false; _factory.ShiftTimeStart = (DateTime)oCell.Row.Cells[_CellStartTime].Value; _factory.ShiftTimeEnd = (DateTime)oCell.Row.Cells[_CellEndTime].Value; _factory.PaintShift((RectangleF)drawParams.Element.RectInsideBorders, drawParams.Graphics); return true; } } // This part draws the border that encompasses single or multiple rows that share a merged cell value else if (drawParams.Element is RowColRegionIntersectionUIElement && drawParams.DrawPhase == Infragistics.Win.DrawPhase.AfterDrawElement) { RowColRegionIntersectionUIElement rowColelem = drawParams.Element as RowColRegionIntersectionUIElement; UltraGridRow currentRow, prevRow, nextRow; foreach (UIElement elem in rowColelem.ChildElements) { if (elem.SelectableItem is UltraGridRow) { currentRow = (UltraGridRow) elem.SelectableItem; if (currentRow.VisibleIndex < 0) continue; // The ActiveRow may be displayed in multiple scroll regions. So // we need to loop through all of them. foreach (RowScrollRegion rsr in _grid.DisplayLayout.RowScrollRegions) { foreach (ColScrollRegion csr in _grid.DisplayLayout.ColScrollRegions) { UIElement activeRowUIElement = currentRow.GetUIElement(rsr, csr); if (activeRowUIElement != null) { Border3DSide borders = Border3DSide.Left | Border3DSide.Right; prevRow = currentRow.GetSibling(SiblingRow.Previous , false, true, false); if (prevRow == null || currentRow.VisibleIndex == 0) borders |= Border3DSide.Top; nextRow = currentRow.GetSibling(SiblingRow.Next, false, true, false); // ShiftDate is the merge cell column key if (nextRow == null || nextRow.Cells["ShiftDate"].IsMergedWith(currentRow.Cells["ShiftDate"]) == false) borders |= Border3DSide.Bottom; Rectangle activeRowRect = activeRowUIElement.Rect; drawParams.DrawBorders( UIElementBorderStyle.Rounded1Etched , borders , Color.Sienna , Color.Blue , activeRowRect , drawParams.InvalidRect); } } } } } return true; } return false; }
I havent tried this but you may be able to do something like this. This does not take into account multiple columns of merged cells.
MergedCellUIElement elem = drawParams.Element as MergedCellUIElement;
currentRow = lastRow =elem.Row;
UltraGridCell firstCell = elem.Cell;
currentRow = currentRow.GetSibling(SiblingRow.Next, false, true, false);
{
// draw left, right border on currentRow
lastRow = currentRow;
}
// draw left, bottom, right border on last row
Thanks, not at my computer atm to check, however, its not the merge cell itself I am trying to draw a border around - its a single thick line border around the whole group of rows that share the same merge cell value.
I.e
merge cell / Date || Person name || Cost
Monday || Fred || 100
Monday || John || 200
Tuesday || Ben || 210
The first column is the merge cell so I am trying to draw a thick line border around both the rows for Monday and a border seperately for Tuesday.