Drawing on a CoveredRange

I read the manual about drawing on a cell (i.e. DrawCell & CellDrawn), but I plan to use the CoveredRange, how will the covered ranged be referenced? Will it be the TopLeft of the cell and then I just use either event to draw in the CoveredRange cell?

Thanks in advance.


1 Reply

RB Ragamathulla B Syncfusion Team August 9, 2011 03:23 PM UTC

Hi Marion,

We regret deeply for the delay.

To achieve the desired behavior in mouse down event, please refer the dashboard sample “Custom Cell Range Demo” .The following code explain the same.

void gridGroupingControl1_TableControlCellDrawn(object sender, GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;
GridTableCellStyleInfoIdentity id = style.TableCellIdentity;

// Employees_Photo column
if (id.Column != null && id.Column.MappingName == Employees_Photo)
{
Group group = id.DisplayElement.ParentGroup;

// Grouped by Customers_ContactName
if (group != null && group.CategoryColumns.Count > 0 && group.CategoryColumns[0].Name == Customers_ContactName)
{
if (group.Records.Count > 0)
{
Record r = group.Records[0];

object value = r.GetValue(id.Column.FieldDescriptor);

// Should be byte[] (image stream ...)
byte[] byteStream = value as byte[];

if (byteStream != null)
{
Graphics graphics = e.Inner.Graphics;
Image image = GridImageUtil.ConvertToImage(byteStream);
Rectangle bounds = e.Inner.Bounds;
bounds = GridMargins.RemoveMargins(bounds, style.TextMargins.ToMargins());
bounds = GridMargins.RemoveMargins(bounds, style.BorderMargins.ToMargins());
style.ImageSizeMode = GridImageSizeMode.CenterImage;
GridImageUtil.DrawImage(image, bounds, graphics, bounds, style, false);
e.Inner.Cancel = true; // signals you did your own drawing.
}
}
}
}
}



The following path contains the sample from the dashboard.

..\..\AppData\Local\Syncfusion\EssentialStudio\{installedVersion}\Windows\Grid.Windows\Samples\2.0\Appearance\Custom Cell Range Demo

Let me know if you have any concern.

Regards,
Ragamathullah B


Loader.
Up arrow icon