delphi AdvBadgeGlowButton1 标题用例

delphi use case on AdvBadgeGlowButton1 caption

如何根据徽章标题使用案例陈述? 尝试过:

procedure TForm2.Button1Click(Sender: TObject);
begin
case AdvBadgeGlowButton1.Caption of
'Test' :     showmessage('Test')
end;
''     :     showmessage('Empty')
end;

但我得到了:

[dcc32 Error] Unit2.pas(29): E2001 Ordinal type required [dcc32 Error]

Unit2.pas(30): E2010 Incompatible types: 'Integer' and 'string'

case 不能用于非 ordinal types 的值(通常为整数值),如错误消息所述。您需要改用 if..else

procedure TForm2.Button1Click(Sender: TObject);
begin
  if AdvBadgeGlowButton1.Caption = 'Test' then
    ShowMessage('Test')
  else if AdvBadgeGlowButton1.Caption = '' then
    ShowMessage('Empty')
  else
    ShowMessage('Got unknown caption ' + AdvBadgeGlowButton1.Caption);
end;