Показ Memo-поля в DBGrid 2



Модем с бодуна трубку снимает:
Гав - тьфу б/\я, Мяу - б/\я, Ш-ш-ш, Ой - пи-и-и...

Используйте следующий код для обработки события OnDrawDataCell у TDBGrid. (Перед запуском программы создайте объект TMemoField для memo поля в Fields Editor).


 procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect:
 TRect;
   Field: TField; State: TGridDrawState);
 var
   P: array [0..1023] of Char; { MemoField buffer }
   BS: TBlobStream;
   S: string;
 begin
   if Field is TMemoField then
   with (Sender as TDBGrid).Canvas do
   begin
 { Table1Notes is the TMemoField }
     BS := TBlobStream.Create(Table1Notes, bmRead);
     FillChar(P, SizeOf(P), #0);
     BS.Read(P, SizeOf(P));
     BS.Free;
     S := StrPas(P);
 { remove carriage returns &  line feeds }
     while Pos(#13, S) >  0 do S[Pos(#13, S)] := ' ';
     while Pos(#10, S) >  0 do S[Pos(#10, S)] := ' ';
 { clear the cell }
     FillRect(Rect);
 { fill cell with memo data }
     TextOut(Rect.Left, Rect.Top, S);
   end;
 end;





Похожие по теме исходники

Memory Manager

Shared Memory

Numbers Memory

xIPMemo

 

Memo Edit Errors Messages

Memory Monitor

Memory Using in System

Simple Memory Seeker

 

Process Memory Map

Линейная интерполяция функции

Интерполяция сплайнами

cyDBGrid

 

Cell Hint in DBGrid

Примеры оформления DBGrid

Пример использования DBGrid