我有一张表格。在formshow中,我将字段的值初始化为字符串网格单元格,但它在单元格的文本下显示一个阴影。我使用波斯字符作为字段的值。
我对英语价值观也做了同样的事情,但它工作得很好。
我很感谢你的建议。
输出示例:

发布于 2013-07-21 20:25:25
在启用了DefaultDrawing的情况下,如果您输入OnDrawCell,文本将已经呈现。
您可以使用UnionRect来获取最终的Rect,该Rect必须被填充(本例中为FillRect)。
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[1,1] := 'Hallo'#13'World';
StringGrid1.Cells[2,2] := 'اهای' +13# + 'جهان';
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
S:String;
drawrect,Fillrect : TRect;
begin
s := (Sender as TStringGrid).Cells[ACol, ARow];
drawrect := Rect;
DrawText((Sender as TStringGrid).Canvas.handle, Pchar(s), Length(s),
drawrect, DT_CALCRECT or DT_WORDBREAK or DT_LEFT);
if (drawrect.bottom - drawrect.Top) > (Sender as TStringGrid)
.RowHeights[ARow] then (Sender as TStringGrid)
.RowHeights[ARow] := (drawrect.bottom - drawrect.Top);
UnionRect(FillRect,Rect,DrawRect);
(Sender as TStringGrid).Canvas.FillRect(FillRect);
DrawText((Sender as TStringGrid).Canvas.handle, Pchar(s), Length(s),
drawrect, DT_WORDBREAK or DT_LEFT);
end;https://stackoverflow.com/questions/17769324
复制相似问题