OZ8*_*8HP -3 delphi devexpress variant tcxgrid
我有以下代码
procedure TfrmJsApplications.colMaintStylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
aColumn: TcxCustomGridTableItem;
aValue: Variant;
begin
inherited;
try
aColumn := Sender.FindItemByName('colApplication_Doc');
aValue := aRecord.Values[aColumn.Index];
if VarToStr(aValue) <> '' then
colMaint.Properties.Buttons[0].Caption := 'Redigere'
else
colMaint.Properties.Buttons[0].Caption := 'Opret'
except
on E:exception do
Logfile.Error('F_JsApplications.colMaintStylesGetContentStyle: ' + E.Message);
end;
Run Code Online (Sandbox Code Playgroud)
在cxGrid中的列上运行.但由于某种原因,我根本无法弄清楚这一行
if VarToStr(aValue) <> '' then
Run Code Online (Sandbox Code Playgroud)
使功能崩溃.我知道当aValue成为Null值时,但据我所知,在这种情况下VarToStr应返回''
的aValue可能不是NULL,但empty.尝试使用支票
if(FindVarData(aValue)^.VType in [varNull, varEmpty])then ...
Run Code Online (Sandbox Code Playgroud)
代替.要么
if VarIsEmpty(aValue) or VarIsNull(aValue) then
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
461 次 |
| 最近记录: |