In the recent release v2013.1 of the DevExpress WinForms Subscription, we introduced a brand new Spreadsheet Control. We are hard at work adding features to it and in v13.1.5 we’ve added support for Custom Draw
Two new events CustomDrawCell and CustomDrawCellBackground are introduced so that you can take control over the painting of each cell.
Image may be NSFW.
Clik here to view.
The usage is very simple:
spreadsheetControl1.CustomDrawCell += HighlightCells;
void HighlightCells(object sender, DevExpress.XtraSpreadsheet.CustomDrawCellEventArgs e)
{
string textToFind = "Waters";
string cellText = e.Cell.DisplayText;
int index = cellText.IndexOf(textToFind, StringComparison.InvariantCultureIgnoreCase);
if (index >= 0)
{
StringFormat format = (StringFormat)StringFormat.GenericTypographic.Clone();
format.SetMeasurableCharacterRanges(newCharacterRange[] { newCharacterRange(index, textToFind.Length) });
Region[] regions = e.Graphics.MeasureCharacterRanges(cellText, e.Font, e.Bounds, format);
RectangleF firstChar = regions[0].GetBounds(e.Graphics);
RectangleF lastChar = regions[regions.Length - 1].GetBounds(e.Graphics);
RectangleF highlightBounds = RectangleF.FromLTRB(
Math.Min(firstChar.Left, lastChar.Left),
Math.Min(firstChar.Top, lastChar.Top),
Math.Max(firstChar.Right, lastChar.Right) + 5,
Math.Max(firstChar.Bottom, lastChar.Bottom));
e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.Yellow), highlightBounds);
}
}
Build v13.1.5 is available for immediate download from the Download Manager.
Cheers,
Azret
Image may be NSFW.Clik here to view.
