gpt4 book ai didi

delphi - TStringGrid 中的箭头指针

转载 作者:行者123 更新时间:2023-12-02 01:17:13 24 4
gpt4 key购买 nike

是否可以将箭头指针添加到 Delphi 7 中的 String Grind 中?您知道我的意思,您可以在 DBGrid 的左侧看到箭头指针。

最佳答案

是的,但不是自动的。您需要手动显示三角形。您可以覆盖网格的OnDrawCell。看来您需要将 FixedCols 设置为 0,因为当行选择更改时,它似乎不会再次重绘固定单元格。

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
aCanvas: TCanvas;
oldColor: TColor;
triangle: array [0..2] of TPoint;
const
spacing = 4;
begin
if (ACol = 0) and (aRow = StringGrid1.Row) then
begin
aCanvas := (Sender as TStringGrid).Canvas; // To avoid with statement
oldColor := aCanvas.Brush.Color;
// Shape the triangle
triangle[0] := TPoint.Create(Rect.Left + spacing, Rect.Top + spacing);
triangle[1] := TPoint.Create(Rect.Left + spacing, Rect.Top + Rect.Height - spacing);
triangle[2] := TPoint.Create(Rect.Left + Rect.Width - spacing, Rect.Top + Rect.Height div 2);

// Draw the triangle
aCanvas.Pen.Color := clBlack;
aCanvas.Brush.Color := clBlack;
aCanvas.Polygon(triangle);
aCanvas.FloodFill(Rect.Left + Rect.Width div 2, Rect.Top + Rect.Height div 2, clBlack, fsSurface);
aCanvas.Brush.Color := oldColor;
end;
end;

这会在框中绘制一个三角形。您应该了解总体思路。

关于delphi - TStringGrid 中的箭头指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16095020/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com