Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.03.03;
Скачать: CL | DM;

Вниз

Как поместить графическое изображение в TDBGrid ?   Найти похожие ветки 

 
Niki   (2003-02-12 14:19) [0]

Как поместить графическое изображение в TDBGrid? (только без использования компонента TImageList)


 
Stas ©   (2003-02-12 14:36) [1]

Проще использовать другой grid.


 
Vlad1 ©   (2003-02-13 22:06) [2]

Например, так:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Grids, DBGrids, ExtCtrls, DBCtrls, StdCtrls;

type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Table1: TTable;
DBNavigator1: TDBNavigator;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Table1.Open;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
Table1.Close;
end;

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var Foto:TBitmap;
OutRect:Trect;
FotoWidth:integer;
begin
OutRect:=Rect;
if Column.FieldName="Photo"
then begin
foto:=TBitmap.Create;
try
foto.Assign(Table1.FieldByName("Photo"));
FotoWidth:=(Rect.Bottom-Rect.Top)*2;
OutRect.Right:=rect.Left+FotoWidth;
DBGrid1.Canvas.StretchDraw(OutRect,Foto);

finally
Foto.Free;
end;//try
OutRect:=Rect;
OutRect.Left:=OutRect.Left+FotoWidth;
DBGrid1.DefaultDrawDataCell(OutRect,column.Field,State);
DBGrid1.Canvas.FillRect(Outrect);
exit;
end;//if;
DBGrid1.DefaultDrawDataCell(OutRect,column.Field,State);
end;

end.



Страницы: 1 вся ветка

Текущий архив: 2003.03.03;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.023 c
3-5450
_BasiL_
2003-02-13 13:15
2003.03.03
DBGrid без BDE


14-5841
rtooo
2003-02-13 20:32
2003.03.03
QReport


9-5371
Fog
2002-09-10 18:45
2003.03.03
Блики линз (просто рассуждение)


9-5365
Dmitriy Polskoy
2002-09-30 10:03
2003.03.03
Спарйты машин


14-5811
IGORYOK
2003-02-13 11:14
2003.03.03
Debug API