title image


Smiley Re: DBGrid DrawColumnCell-Frage
Du musst eine Klasse ableiten und das Zeichnen der Titelleiste selbst Programmieren. z.B.:



type

TDBX = class(TDBGrid)

public

procedure DrawCell(ACol, ARow: Integer;

Rect: TRect; State: TGridDrawState); override;

end;



var

DBG: TDBX;

bm: TBitmap;



procedure TForm1.FormCreate(Sender: TObject);

begin

bm := TBitmap.create;

bm.loadfromfile('D:\Bilder\Led1.bmp');

bm.transparent := true;

DBG := TDBX.create(self);

with DBG do begin

left := 100;

top := 100;

width := 500;

DataSource := DataSource1;

parent := self;

end;

Table1.active := true;

end;



procedure TForm1.FormDestroy(Sender: TObject);

begin

bm.free;

Table1.active := false;

DBG.free;

end;



procedure TDBX.DrawCell(ACol, ARow: Integer;

Rect: TRect; State: TGridDrawState);

begin

if ARow = 0 then begin

with canvas do begin

Font.Color := clBlue; // z.B.

brush.color := clBtnFace;

fillrect(Rect);

pen.color := clBtnHighLight;

moveto(Rect.Left, pred(Rect.Bottom));

lineto(Rect.Left, Rect.Top);

lineto(Rect.Right, Rect.Top);

pen.color := clBTnShadow;

moveto(succ(Rect.Left), pred(Rect.Bottom));

lineto(pred(Rect.Right), pred(Rect.Bottom));

lineto(pred(Rect.Right), Rect.Top);

if aCol = 1 then begin // Bild in erster Spalte

draw(Rect.Left + 1, Rect.top + 1, bm);

inc(Rect.Left, bm.width);

end;

inflaterect(Rect, -2, -2);

if aCol > 0 then

drawtext(handle, PChar(columns[aCol - 1].fieldname), -1, Rect,

DT_SingleLine or DT_VCenter);

end;

end else inherited;

end;



Gruß DBR




Eine Stunde denken spart zehn Stunden programmieren!

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: