Forum > LCL
TStringGrid skinning problem : Image above text
(1/1)
lainz:
I need the image is below the text, but always remains above: How i can fix it? (see the attach selectgrid.png).
--- Code: ---unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
DBGrids;
type
{ TForm1 }
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
Bitmap1: TBitmap;
Bitmap2: TBitmap;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
begin
if (aCol = 0) or (aRow = 0) then begin
StringGrid1.Canvas.StretchDraw(aRect,Bitmap2);
end;
if gdSelected in aState then begin
StringGrid1.Canvas.StretchDraw(aRect,Bitmap1);
end;
StringGrid1.Cells[aCol,aRow] := 'Hello';
end;
initialization
Bitmap1 := TBitmap.Create;
Bitmap1.LoadFromFile('gradient.bmp');
Bitmap2 := TBitmap.Create;
Bitmap2.LoadFromFile('gradient2.bmp');
end.
--- End code ---
ivan17:
write the text above the bitmap (meaning draw it AFTER you draw bitmap):
1: StringGrid1.Canvas.StretchDraw(aRect,Bitmap1);
2: StringGrid1.Canvas.TextRect(aRect, 2, 5, 'Hello'); // or the value of cells property
(that 2 is ok, but i;d recalculate that 5 on app atart)
Navigation
[0] Message Index