Fórum imagem em db para dbgrid, só uma duvida? #317293
25/03/2006
0
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixRect : TRect;
bmpWidth : integer;
imgIndex : integer;
begin
fixRect := Rect;
if Column.Field = EmployeeTableBMP then
begin
Bitmap := TBitmap.Create;
try
//Pega o grafico da Tabela
Bitmap.Assign(EmployeeTable.FieldByName(´BMP´));
//Desenha
DBGrid1.Canvas.StretchDraw(fixRect, bitmap);
finally
bitmap.Free;
end;
// Limpa a saida do Retangulo
fixRect := Rect;
fixRect.Left := fixRect.Left + bmpWidth;
end;
//draw default text (fixed position)
DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State);
end;
===============================================
mas quando tenho compilar da o seguinte erro:
Undeclared indentifier: ´EmployeeTableBMP´
Será que alguém pode me ajudar?
Obrigado.
Juniorprog
Curtir tópico
+ 0Posts
25/03/2006
Martins
A Declaração não foi identificada
[color=red:38e5bc0153][b:38e5bc0153]EmployeeTableBMP[/b:38e5bc0153][/color:38e5bc0153] provavelmente isso aqui :arrow: [color=red:38e5bc0153]if Column.Field = EmployeeTableBMP then [/color:38e5bc0153]
Não sei se vc está usando a tabela Employee, mas [b:38e5bc0153]Column.Field[/b:38e5bc0153] deve ser igual ao campo BMP de sua tabela, se vc pegou esse exemplo e não modificou para atender a sua necessidade, faça-o e depois retorne aqui no fórum.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var bitmap : TBitmap; fixRect : TRect; bmpWidth : integer; imgIndex : integer; begin fixRect := Rect; // Se o campo da coluna for igual ao campo [b]blob[/b] então faça... if Column.Field = SuaTabelaSeuCampoBlob then begin Bitmap := TBitmap.Create; try //Pega o grafico da Tabela Bitmap.Assign(SuaTabela.FieldByName(´SeuCampoBlob´)); //Desenha DBGrid1.Canvas.StretchDraw(fixRect, bitmap); finally bitmap.Free; end; // Limpa a saida do Retangulo fixRect := Rect; fixRect.Left := fixRect.Left + bmpWidth; end; //draw default text (fixed position) DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State); end;
Boa sorte!!
Gostei + 0
27/03/2006
Juniorprog
Valeu.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var bitmap : TBitmap; fixRect : TRect; bmpWidth : integer; imgIndex : integer; begin fixRect := Rect; // Se o campo da coluna for igual ao campo [b]blob[/b] então faça... if Column.Field = SuaTabelaSeuCampoBlob then begin Bitmap := TBitmap.Create; try //Pega o grafico da Tabela Bitmap.Assign(SuaTabela.FieldByName(´SeuCampoBlob´)); //Desenha DBGrid1.Canvas.StretchDraw(fixRect, bitmap); finally bitmap.Free; end; // Limpa a saida do Retangulo fixRect := Rect; fixRect.Left := fixRect.Left + bmpWidth; end; //draw default text (fixed position) DBGrid1.DefaultDrawColumnCell(fixRect, DataCol, Column, State); end;
Boa sorte!!
Gostei + 0
27/03/2006
Martins
Gostei + 0