При попытке вывести данные из БД в DBGrid, есть одна проблема. Данные в DBGrid могут отображаться как (WIDEMEMO). Что бы это подправить надо внести изменения в одну из двух процедур отрисовки.
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
var
Grid : TStringGrid;
Texto : String;
Rectangulo : TRect;
begin
Rectangulo:=Rect;
Grid := TStringGrid(Sender);
if Field.IsBlob then begin
Grid.Canvas.FillRect(Rect);
Texto := Field.AsString;
DrawText( Grid.Canvas.Handle,
PChar(Texto),
StrLen(PChar(Texto)),
Rectangulo,
DT_WORDBREAK);
end;
end;
Или вот другой вариант
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Assigned(Column) then
begin
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, ' '+Column.Field.AsString);
end;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
var
Grid : TStringGrid;
Texto : String;
Rectangulo : TRect;
begin
Rectangulo:=Rect;
Grid := TStringGrid(Sender);
if Field.IsBlob then begin
Grid.Canvas.FillRect(Rect);
Texto := Field.AsString;
DrawText( Grid.Canvas.Handle,
PChar(Texto),
StrLen(PChar(Texto)),
Rectangulo,
DT_WORDBREAK);
end;
end;
Или вот другой вариант
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Assigned(Column) then
begin
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, ' '+Column.Field.AsString);
end;
end;