TTMSFNCDataGrid - Memos

Hi!
How can we edit a memo field in FNCDataGrid when using a database adapter ?
No way of Editor type = getMemo showing any editor.

Trying to see a memo inplace editor using biolife clientdataset demo neither worked.
Couldn't find a way to let it edit Notes column as a memo. Not even using Editor = getEdit.

Editing demo , where there's no adapter, it opened an inplace editor when i put column 7 Editor = getMemo. Just it. No dropdown, just opened an editor within the cell rect.

I couldn't even try to setup a memodropdown as a custom editor, because the events did not fire with my database adapter connected and the column field is a tmemofield.

Please urgent help needed.
Thanks.

But with a database adapter, neither showed an editor, neither fired none of the events ongetinplaceeditortype, properties, or class (i tried it when inserting a new record, when the memo content is blank).

ftMemo is part of non editable fields which means that ftMemo is likely to be stored as binary format. Assigning a string (which is what the default or memo inplace editor does) is potentially causing issues. Because the biolife.xml is actually storing ftMemo as a string, you can use the following functionality to allow editing the memo directly as a string in the grid (applied to BiolifeClientDataSet demo)

  1. Add All Fields to the DataSet
  2. Select the Notes field and assign the OnSetText event
  3. Use the following code
procedure TForm1.ClientDataSet1NotesSetText(Sender: TField;
  const Text: string);
begin
  Sender.AsString := Text;
end;

Yes .. I found it 2 minutes ago, after debugging everything, step by step.

const
  { The following field types do not support assignment as text, unless the
    field object's OnSetText event is assigned to perform the text to
    binary conversion. }
  ftNonTextTypes = [ftBytes, ftVarBytes, ftBlob, ftMemo, ftGraphic, ftFmtMemo,
    ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftADT, ftArray,
    ftReference, ftDataSet];

:eyes::face_with_monocle:never

The component should be "kind" to those who use ftMemo as it is meant to be.
I've been 4 hours over a problem whereas I shouldn't have ran into this problem.

Now it opens an editor inside of the cell. Just one line.
How do we make it larger, beyond the cell rect? Is there any way of using a dropdown memo ?

Could make it show a tadvmemodropdown. Eats all the cell borders, but at least works.

GetInplaceEditorType:
    AInplaceEditorType := getCustom;

GetInplaceEditorClass:
    AInplaceEditorClass := TAdvMemoDropDown;

BeforeCloseInplaceEditor:
  if AInplaceEditor is tadvmemodropdown then
    AValue := (AInplaceEditor as tadvmemodropdown).MemoText.Text;

It's unclear why you state it is never saved as a binary format?

ftMemo is part of ftNonTextTypes, and the default behavior is that it cannot be accessed as a string, unless the OnSetText is implemented. Which clearly states in the code documentation. We cannot predict in which format ftMemo is stored. Coincidentally it is readable as string in TClientDataSet, but it's not guaranteed that every dataset stores ftMemo as a string. Typically, it's stored in a different binary text format to preserve encoding.

Sorry ... that "never" meant: I never use memo to store binary data.
Problems when English isn't one's native language. I understood what you wrote as "people usually uses memo fields to store binary data" . :man_facepalming:t2:

But ftMemo (not widememo, not fmtmemo) accepts simple text assignmets. Why is it in this set ?
:man_shrugging:t2: Anyway, sure there's some kind of non-compatible assignment behind the scenes that I'm not used to.

No worries :slight_smile:

Your guess is as good as mine, ftMemo is part of that array, which means I need to handle it differently. The reason why is unknown to me, I would assume that if you have text fields, you can define it as a string, which would map on one of the string fields. I suppose it was more of an issue in the older Delphi days.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.