luca's option is a workaround, but doesn't work with database GUI components.
It doesn't? How is that?
I assume you're asking "Why doesn't AnsiToUTF8(qry.FieldByName('Fieldname').AsString) work for the DB aware GUI controls?"
Quick answer - because those controls populate their value directly from the dataset, there's no place that Luca's workaround can be applied.
Well actually, that's not true. Moving away from your question @Taaz
@Mhmd60 Try the following code...
...
TForm1 = Class(TForm)
Procedure DatasetOnGetText(Sender: TField; Var aText: Ansistring; DisplayText: Boolean);
Procedure InitialiseDataset;
..
Procedure TForm1.DatasetOnGetText(Sender: TField; Var aText: Ansistring;
DisplayText: Boolean);
Begin
aText := AnsiToUTF8(Sender.AsString);
End;
Procedure TForm1.InitialiseDataset;
Var
i: Integer;
oField: TField;
Begin
If Not Assigned(FDataset) Then
Exit;
For i := 0 To FDataset.FieldCount - 1 Do
Begin
oField := FDataset.Fields[i];
If oField.DataType =ftString Then
oField.OnGetText := @DatasetOnGetText;
End;
End;
Then just find an appropriate place to call InitialiseDataset;. Presumably just after your Dataset.Open;