Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.01 c
7-5886
FoxM
2003-01-04 12:49
2003.03.03
res - файл


3-5430
Vint
2003-02-11 13:05
2003.03.03
ASCII


14-5805
Анонимный невротик
2003-02-11 03:05
2003.03.03
Музыка


1-5551
Lex
2003-02-20 15:00
2003.03.03
Ребята, помогите пожалуйста решить задачу на паскале! Очень надо!


3-5445
chadnov
2003-02-11 15:51
2003.03.03
Как выровнять столбцы в DBGrid е




   Наверх