TwwDBGrid change displayed text
In TwwDBGrid.OnDrawDataCell, I wish to display text other than what has been put in the cell. When I simply do "Field.Text = 'xxx';", I get the error message "Dataset not in Edit or Append mode".
I do not want to change what is in the database, simply what is displayed in the grid. How do I do that?
Thanks
-
One way to handle this is to use the Tfield.onGetText event. This event allows you to change what is displayed for the field in the grid. To access the tfield do the following.
1. Dvl-Click your Dataset to bring up the fields editor, and add all the fields if you have not already done so.
2. Select the tfield you want to change the display text for and then put code in the OnGetText event.
3. Put code in the event to assign your text. For instance...
procedure TFPDataModule.CustomerDataMemBuyerGetText(Sender: TField;
var Text: string; DisplayText: Boolean);
begin
if DisplayText then Text:= Sender.AsString + ' More text';
end;
Please sign in to leave a comment.
Comments
2 comments