Problem with Strings and TVirtualDataSet
Posted: Wed 07 Apr 2021 10:47
When trying to work with guids represented as strings I came across the following problem.
If a string field in a TVirtualDataset is defined as having a size of, say, 38, then when the string field displays a string of length 38 the last character is shown as an unprintable character.
To reproduce this open the virtual dataset demo. On line 156 the DeptDataSet field DName has a size of 14.
On line 130 change
DeptList.Add(TDept.Create(10, 'ACCOUNTING', 'NEW YORK'));
to
DeptList.Add(TDept.Create(10, 'ACCOUNTING1234', 'NEW YORK'));
so the length of the string to be displayed is now 14 characters.
Run the program. Expand the DName column and inspect the last character displayed.
If a string field in a TVirtualDataset is defined as having a size of, say, 38, then when the string field displays a string of length 38 the last character is shown as an unprintable character.
To reproduce this open the virtual dataset demo. On line 156 the DeptDataSet field DName has a size of 14.
On line 130 change
DeptList.Add(TDept.Create(10, 'ACCOUNTING', 'NEW YORK'));
to
DeptList.Add(TDept.Create(10, 'ACCOUNTING1234', 'NEW YORK'));
so the length of the string to be displayed is now 14 characters.
Run the program. Expand the DName column and inspect the last character displayed.