CB
Clay Burch
Syncfusion Team
September 29, 2009 10:05 AM UTC
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);
}
PO
Puthirak OM
September 29, 2009 01:59 PM UTC
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
CB
Clay Burch
Syncfusion Team
September 29, 2009 02:52 PM UTC
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];
PO
Puthirak OM
September 30, 2009 08:26 AM UTC
Thanks Clay,
It works.
But i'll stick with the less than perfect code. It suit more
my purpose ;-)
Thanks,
P.OM
Reportive SA
MS
Mohamed Suhaib Fahad A.
Syncfusion Team
October 16, 2009 09:35 AM UTC
Hi Puthirak,
Thanks for your feedbacks.
Thanks,
Fahad