What properties determine the sizes of the ClientDataSet fields?

I have an application that uses ClientDataSets and local file storage. Some information is displayed in the database grid, and I found that it is cropped - the first 500 characters or so lines were displayed, but the main fields should have been longer. Therefore, I returned to my code and increased the size of the base FieldDefs fields, as well as their display width. I also created a new dataset (during development). Finally, I launched the application and created a new database. However, only ~ 500 characters were displayed.

Where should I see what limits my field lengths?

+3
source share
1 answer

, TDBGrid, 500 , . ( , VCL, Grids.pas.)

, TDBGrid . , .

- ftMemo, . TDBGrid, (MEMO), , TEdit TRichEdit / .

TDBGrid, TClientDataSet CDS (, ) CDS.FieldDefs Object Inspector:

Column      Persistent Name    FieldType    Size
------      ---------------    ---------    ----
ID          CDSID              ftInteger     0
Name        CDSName            ftString     25
Notes       CDSNotes           ftMemo        0

, FileName :

procedure TForm1.FormCreate(Sender: TObject);
begin
  if not FileExists(CDS.FileName) then
  begin
    CDS.CreateDataSet;
    CDS.Active := True;
    CDS.InsertRecord([1, 'John Smith', 'This is some longer text'#13'for testing.']);
    CDS.InsertRecord([2, 'Fred Jones', 'A note about Fred goes'#13'here for now.']);
    CDS.Active := False;
  end;
  CDS.Active := True;
end;

a TDataSource DataSource CDS. TDBGrid DataSet DataSource1.

TDBGrid, "" OnCellClick ( , ):

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
  if Column.FieldName := 'CDSNotes' then
    ShowMessage(Column.Field.AsString); // Display other form here instead
end;

CDSNotes 1 TDBGrid:

enter image description here

TDBGrid, - :

procedure TForm2.CDSNotesGetText(Sender: TField; var Text: string;
  DisplayText: Boolean);
begin
  // Again, a trivial example using an arbitrary chunk of the first 20
  // characters just for demo purposes.
  if DisplayText then
    Text := Copy(Sender.AsString, 1, 20)
  else
    // Not for display only; return all the text.
    Text := Sender.AsString;
end;

:

enter image description here

+4

All Articles