当输入不是“Admin”时,我需要禁用 Next 按钮。
类似的东西:
procedure EditKeyPress(Sender: TObject; var Key: Char);
begin
{ enable the next button if the value in the box is admin; disable otherwise }
WizardForm.NextButton.Enabled:=InputPage6.values[EditIndex2].Text = 'Admin'
end;
答案 0 :(得分:3)
实施输入框OnChange
事件。您还需要确保在激活自定义页面时更新按钮状态。您可以使用OnActivate
事件(或CurPageChanged
事件函数)。
var
Page: TInputQueryWizardPage;
procedure ValidatePage;
begin
WizardForm.NextButton.Enabled := (CompareText(Page.Values[0], 'Admin') = 0);
end;
procedure EditChange(Sender: TObject);
begin
ValidatePage;
end;
procedure PageActivate(Sender: TWizardPage);
begin
ValidatePage;
end;
procedure InitializeWizard();
begin
Page := CreateInputQueryPage(...);
{ To disable the Next button initially [when box is empty] }
Page.OnActivate := @PageActivate;
Page.Add(..., False);
{ Update Next button state on any input change (typing, copy&paste, whatever) }
Page.Edits[0].OnChange := @EditChange;
end;
有关其他方法,请参阅: