本文整理汇总了C#中GridVirtual.PositionToCellRange方法的典型用法代码示例。如果您正苦于以下问题:C# GridVirtual.PositionToCellRange方法的具体用法?C# GridVirtual.PositionToCellRange怎么用?C# GridVirtual.PositionToCellRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridVirtual
的用法示例。
在下文中一共展示了GridVirtual.PositionToCellRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics,
Range rangeToExport, System.Drawing.Point destinationLocation)
{
if (rangeToExport.IsEmpty())
return;
System.Drawing.Point cellPoint = destinationLocation;
System.Drawing.Point deltaPoint = destinationLocation;
using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
{
for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
{
int rowHeight = grid.Rows.GetHeight(r);
for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
{
Rectangle cellRectangle;
Position pos = new Position(r, c);
Size cellSize = new Size(grid.Columns.GetWidth(c), rowHeight);
Range range = grid.PositionToCellRange(pos);
//support for RowSpan or ColSpan
//Note: for now I draw only the merged cell at the first position
// (this can cause a problem if you export partial range that contains a partial merged cells)
if ( range.ColumnsCount > 1 || range.RowsCount > 1)
{
//Is the first position
if (range.Start == pos)
{
Size rangeSize = grid.RangeToSize(range);
cellRectangle = new Rectangle(cellPoint,
rangeSize);
}
else
cellRectangle = Rectangle.Empty;
}
else
{
cellRectangle = new Rectangle(cellPoint, cellSize);
}
if (cellRectangle.IsEmpty == false)
{
Cells.ICellVirtual cell = grid.GetCell(pos);
CellContext context = new CellContext(grid, pos, cell);
ExportCell(context, graphicsCache, cellRectangle);
}
cellPoint = new Point(cellPoint.X + cellSize.Width, cellPoint.Y);
}
cellPoint = new Point(destinationLocation.X, cellPoint.Y + rowHeight);
}
}
}
示例2: SetHeight
private void SetHeight(GridVirtual grid, Position position, int height)
{
Range range = grid.PositionToCellRange(position);
int heightForCol = height / range.RowsCount;
for (int r = range.Start.Row; r <= range.End.Row; r++)
grid.Rows.SetHeight(r, heightForCol);
}
示例3: SetWidth
private void SetWidth(GridVirtual grid, Position position, int width)
{
Range range = grid.PositionToCellRange(position);
int widthForCol = width / range.ColumnsCount;
for (int c = range.Start.Column; c <= range.End.Column; c++)
grid.Columns.SetWidth(c, widthForCol);
}