Hi,
I was able to reproduce this in a simple VCL forms app.
The "TextAfter" setting of a NxVirtualColumn does not work in a NextDbGrid. It works fine, however, in a NextGrid. TextBefore works as well.
I tried to find the problem in the code, but I couldn't. It looks like the field FTextAfter is set properly, but when the Text is concated, "TextAfter" returns an empty string.
Thanks for any help..
Michael
TextBefore in VirtualColumn does not work
Started by tarnschaf, Feb 25 2012 08:29 PM
1 reply to this topic
#1
Posted 25 February 2012 - 08:29 PM
#2
Posted 01 March 2012 - 03:26 AM
EDIT: It looked like a Delphi bug, but I found out that it is a bug of the DB Grid component. 
EDIT 2: Finally I found the real problem.
The main problem seems to be inside the class TNxDbColumns. The function GetItem is overwritten to always return a TNxDBCustomColumn. Although I understand that this saves a lot of code, it is dangerous as at least one column type (the virtual column) does not have TNxDBCustomColumns as a base class.
Many times there is a (run-time) check if the column is in fact a DB column before accessing specific properties. But at some points the check is missing or too late -> this leads to unexpected program behaviour.
If I may recommend you one thing: Don't overwrite the GetItem / Item[] methods. This way type problems will show up at compile time. And, by the way, this also solved the problem with "TextAfter". I assume it will fix some access violation errors I got when including a virtual column in a DB grid as well.
If you are interested in my changes, drop me a note and I will send the file to you - however, I think the fix is straightforward.
EDIT 2: Finally I found the real problem.
The main problem seems to be inside the class TNxDbColumns. The function GetItem is overwritten to always return a TNxDBCustomColumn. Although I understand that this saves a lot of code, it is dangerous as at least one column type (the virtual column) does not have TNxDBCustomColumns as a base class.
Many times there is a (run-time) check if the column is in fact a DB column before accessing specific properties. But at some points the check is missing or too late -> this leads to unexpected program behaviour.
If I may recommend you one thing: Don't overwrite the GetItem / Item[] methods. This way type problems will show up at compile time. And, by the way, this also solved the problem with "TextAfter". I assume it will fix some access violation errors I got when including a virtual column in a DB grid as well.
If you are interested in my changes, drop me a note and I will send the file to you - however, I think the fix is straightforward.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users










