TField.OnGetText中'Text'参数的默认值是什么 [英] What is the default value of 'Text' parameter in TField.OnGetText

查看:87
本文介绍了TField.OnGetText中'Text'参数的默认值是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在字段 Score TField.OnGetText 事件中附加了一个过程,如下所示:

I have a procedure attached to TField.OnGetText event of field Score like this:

procedure TMyForm.GetScoreText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
    if StrToInt(Sender.AsString) >= 80 and StrToInt(Sender.AsString) <= 100 then
        Text := 'Great!';
    else if StrToInt(Sender.AsString) >= 60 and StrToInt(Sender.AsString) < 80 then
        Text := 'Good';
end;

来自 OnGetText 文档,我知道当没有 OnGetText时处理程序定义后,该字段的 Text 属性的名称为 AsString 属性。但是我的问题是, var 参数 Text 的值是多少? OnGetText 定义,但为该字段的当前值定义了 Text 。在我的情况下,当字段得分的值小于60时,文本会得到什么值?是 Null ,还是空字符串,还是其他?我需要明确地知道它,因为有些逻辑取决于所显示的值。

From OnGetText documentation, I know that when there is no OnGetText handler defined, the Text property of the field is the name as AsString property. But my question is, what value does the var parameter Text get there is an OnGetText defined but the the Text is defined for the current value of the field. That is in my case, what value does the Text get when value of the field Score is something less than 60? Is it Null, or empty string, or something else? I need to know it explicitly because there is some logic that depends on the value being displayed.

我从此 SO发布,当 OnGetText 处理程序过程没有代码,即该过程的主体为空。

I learned from this SO post that there was nothing being displayed for the field when the OnGetText handler procedure has no code, that is body of the procedure is empty.

推荐答案

何时分配了 OnGetText Text 自变量未返回任何内容,则结果为空字符串。

When an OnGetText assigned and nothing returns in the Text argument, then the result is an empty string.

查看 Db 来源:

function TField.GetDisplayText: string;
begin
  Result := '';
  if Assigned(FOnGetText) then
    FOnGetText(Self, Result, True) else
    GetText(Result, True);
end;

结果最初设置为空字符串,并将其传递给 FOnGetText (如果已分配)。

The Result initially is set to an empty string and passes it to the FOnGetText if it was assigned.

这篇关于TField.OnGetText中'Text'参数的默认值是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆