We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Drawing on a CoveredRange

Thread ID:

Created:

Updated:

Platform:

Replies:

100408 Aug 4,2011 03:33 PM Aug 9,2011 11:23 AM Windows Forms 1
loading
Tags: GridControl
Marion Smith
Asked On August 4, 2011 03:33 PM

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.


Ragamathulla B [Syncfusion]
Replied On August 9, 2011 11:23 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;