Главная страница
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.021 c
3-5462
Tornado
2003-02-13 16:53
2003.03.03
Access -> MySQL


4-5922
Diamond Cat
2003-01-15 02:53
2003.03.03
Shell_NotifyIcon


14-5796
Дмитрий К.К.
2003-02-12 10:09
2003.03.03
Слово о MS Front Page


14-5738
New
2003-02-15 09:32
2003.03.03
Проблема с определением логина


14-5818
FROM_X
2003-02-13 13:44
2003.03.03
DirectSS Кто с ним работал?