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 rect of a cell

Thread ID:

Created:

Updated:

Platform:

Replies:

90371 Sep 28,2009 12:58 PM Oct 16,2009 05:35 AM WPF 5
loading
Tags: GridControl
Puthirak OM
Asked On September 28, 2009 12:58 PM

Hi,

How can i get the drawing rectangle of a cell or covered cell?

Thanks,

P.OM
Reportive SA

Clay Burch [Syncfusion]
Replied On September 29, 2009 06:05 AM

To handle single cells as well as covered cells, try code like this to see if it serves your needs.

Rect GetCellRect(int rowIndex, int columnIndex, GridControlBase grid)
{
GridRangeInfo range = GridRangeInfo.Cell(rowIndex, columnIndex);
if (grid.Model.CoveredCells.Find(rowIndex, columnIndex, out range))
{
range = range.ExpandRange(1, 1, grid.Model.RowCount, grid.Model.ColumnCount);
}

double width = 0;
for(int i = columnIndex; i <= range.Right; ++i)
width += grid.Model.ColumnWidths[i];

double height = 0;
for (int i = rowIndex; i <= range.Bottom; ++i)
height += grid.Model.RowHeights[i];

double yLocation = grid.ScrollRows.GetVisibleLineAtLineIndex(rowIndex).Origin;
double xLocation = grid.ScrollColumns.GetVisibleLineAtLineIndex(columnIndex).Origin;
return new Rect(xLocation, yLocation, width, height);
}

Puthirak OM
Replied On September 29, 2009 09:59 AM

Hi,

Thanks for the code, it serve my needs, even if the calculation of the rectangle of covered cell doesn't work.

Thanks,

P.OM
Reportive SA

Clay Burch [Syncfusion]
Replied On September 29, 2009 10:52 AM

The coveredcell code worked for me when I tried it, but I always passed it the top-left cell when requesting the covered cell rect. If you are not passing it the top-left cell, tweak the code as follows:

double width = 0;
for(int i = range.Left; i <= range.Right; ++i)
width += grid.Model.ColumnWidths[i];

double height = 0;
for (int i = range.Top; i <= range.Bottom; ++i)
height += grid.Model.RowHeights[i];


Puthirak OM
Replied On September 30, 2009 04:26 AM

Thanks Clay,

It works.
But i'll stick with the less than perfect code. It suit more
my purpose ;-)

Thanks,

P.OM
Reportive SA

Mohamed Suhaib Fahad A. [Syncfusion]
Replied On October 16, 2009 05:35 AM

Hi Puthirak,

Thanks for your feedbacks.

Thanks,
Fahad

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.

;