Edited: I want to draw a vertical centered TIcon graphic and Text on a TJvDBGrid (Project's Jedi descendant of TDBGrid). I tried to disable the DefaultDrawing method of JvDBGrid and override it, but I only could fill the cells with black (I think that my code is incomplete to do the override).
Now I succeeded draw the Icon on Cell and the Text remains the same with Default Drawing. How I can center the Icon (vertical and horizontal) and the Text (just vertical ), like this?
Here is my code:
procedure TFrmXXX.JvDBGridXXXDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Icon: TIcon;
fixRect: TRect;
imgWidth: Integer;
begin
fixRect := Rect;
if Column.Index = 0 then //always the first one
begin
Icon := GetIcon; //Returns TIcon object
try
imgWidth := (Rect.Bottom - Rect.Top);
fixRect.Right := Rect.Left + imgWidth;
(Sender as TJvDBGrid).Canvas.StretchDraw(fixRect, Icon);
finally
Icon.Free;
end;
fixRect := Rect;
fixRect.Left := fixRect.Left + imgWidth;
end;
(Sender as TJvDBGrid).DefaultDrawColumnCell(fixRect, DataCol, Column, State);
end;