这是一个 SpreadsheetGear Grid 特定问题。我知道您可以向单元格添加评论,并且该单元格会自动在右上角获得红色三角形标记。但我需要在任何单元格角落添加一个小三角形(不同颜色)以表示一些特别的东西。有可能做到吗?
UPATE:这是我根据丹尼尔的建议在单元格的任何角落添加一个三角形的结果。
public void AddTriangleShapeToCorner(IWorksheet worksheet, int row, int col, CellCorners cellCorner)
{
const double width = 5, height = 5;
double xOffset = 0, yOffset = 0;
IWorksheetWindowInfo windowInfo = worksheet.WindowInfo;
if (cellCorner == CellCorners.TopRight || cellCorner == CellCorners.BottomRight)
{
col++;
xOffset = width;
}
if (cellCorner == CellCorners.BottomLeft || cellCorner == CellCorners.BottomRight)
{
row++;
yOffset = height;
}
double top = windowInfo.RowToPoints(row) - yOffset;
double left = windowInfo.ColumnToPoints(col) - xOffset;
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.RightTriangle, left, top, width, height);
shape.Line.Visible = false; // line at top-left corner is not sharp, so turn it off.
shape.Placement = Placement.Move; // make the shape move with cell. NOTE: it doesn't work for top-right and bottom-right corners.
if (cellCorner == CellCorners.TopLeft || cellCorner == CellCorners.TopRight)
shape.VerticalFlip = true;
if (cellCorner == CellCorners.TopRight || cellCorner == CellCorners.BottomRight)
shape.HorizontalFlip = true;
}