AdvBadgeGlowButton1标题上的delphi用例

时间:2019-01-28 12:27:37

标签: delphi tms

如何根据徽章标题使用case语句? 尝试过:

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

但得到了:

  

[dcc32错误] Unit2.pas(29):需要E2001序数类型[dcc32错误]

     

Unit2.pas(30):E2010不兼容的类型:“整数”和“字符串”

1 个答案:

答案 0 :(得分:0)

错误消息指出,

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;