Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Design question - dbmemo |
Thu, Dec 3 2009 10:04 AM | Permanent Link |
"Robert" | what's the best way to display a memo in a dbgrid? so that it shows the
first x characters, and then when double click they can read and edit. Robert |
Thu, Dec 3 2009 10:29 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Robert,
<< what's the best way to display a memo in a dbgrid? so that it shows the first x characters, and then when double click they can read and edit. >> Which version of Delphi ? In our ElevateDB Manager, we do so for all versions of Delphi with code like this: procedure TMainForm.GetBlobText(Sender: TField; var Text: String; DisplayText: Boolean); begin if DisplayText and Sender.IsNull then Text:='NULL' else begin case Sender.DataType of {$IFDEF EDB_UNICODE} ftWideMemo: begin if ShowCLOBsInGrid then begin Text:=Sender.AsWideString; {$ELSE} ftMemo: begin if ShowCLOBsInGrid then begin Text:=Sender.AsString; {$ENDIF} if (Length(Text) > CLOBCharacters) then Text:=Copy(Text,1,CLOBCharacters)+'...'; Text:=StringReplace(Text,CR,' ',[rfReplaceAll]); Text:=StringReplace(Text,LF,' ',[rfReplaceAll]); end else Text:='CLOB'; end; ftBlob: begin if ShowBLOBsInGrid then Text:=IntToStr(TBlobField(Sender).BlobSize)+' bytes' else Text:='BLOB'; end; end; end; end; procedure TMainForm.SetBlobText(Sender: TField; const Text: String); begin Sender.AsString:=Text; end; procedure TMainForm.SetupFields(DataSet: TDataSet); var I: Integer; begin with DataSet do begin for I:=0 to FieldCount-1 do begin with Fields[I] do begin case DataType of {$IFDEF EDB_UNICODE} ftWideMemo: {$ELSE} ftMemo: {$ENDIF} begin OnGetText:=GetBlobText; OnSetText:=SetBlobText; DisplayWidth:=CLOBDisplayWidth; end; ftBlob: begin OnGetText:=GetBlobText; DisplayWidth:=BLOBDisplayWidth; end; end; end; end; end; end; And, here is the code that "massages" the normal DBGrid to allow editing of memos in the grid for BDS 2006 and lower (I think they started allowing this in D2007, but it may have been D2009): TEDBDBGrid = class(TDBGrid) private FOnEditShowing: TNotifyEvent; protected function GetEditLimit: Integer; override; procedure DoEditShowing; public property EditorMode; property InplaceEditor; published property OnEditShowing: TNotifyEvent read FOnEditShowing write FOnEditShowing; end; { TEDBDBGrid } function TEDBDBGrid.GetEditLimit: Integer; begin if Assigned(SelectedField) and (SelectedField.DataType=ftMemo) then Result:=High(Integer) else Result:=inherited GetEditLimit; DoEditShowing; end; procedure TEDBDBGrid.DoEditShowing; begin if Assigned(FOnEditShowing) then FOnEditShowing(Self); end; -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Dec 3 2009 4:28 PM | Permanent Link |
"Robert" | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:28AC8539-9FBC-49AE-A6D1-7C77561F9D50@news.elevatesoft.com... > Robert, > > << what's the best way to display a memo in a dbgrid? so that it shows the > first x characters, and then when double click they can read and edit. >> > > Which version of Delphi ? In our ElevateDB Manager, we do so for all > versions of Delphi with code like this: > Thanks a lot for the info. I found that I can edit a string field using a dbmemo (max string length is more than adequate for my needs). So a read only grid on top and a dbmemo seem to do the job. The grid shows the first few words of the string and a few other fields, and the whole string is displayed in the dbmemo. Do you see any problems with this? Robert |
Sun, Dec 6 2009 6:39 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Robert,
<< Thanks a lot for the info. I found that I can edit a string field using a dbmemo (max string length is more than adequate for my needs). So a read only grid on top and a dbmemo seem to do the job. The grid shows the first few words of the string and a few other fields, and the whole string is displayed in the dbmemo. Do you see any problems with this? >> No, that will work fine. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, March 29, 2024 at 03:30 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |