gpt4 book ai didi

delphi - TToolButton 的AllowAllUp 属性不起作用

转载 作者:行者123 更新时间:2023-12-02 05:13:17 30 4
gpt4 key购买 nike

我使用的是Delphi XE5。

我正在尝试按照 Delphi 关于 TToolButton 组件的帮助进行锻炼。

Delphi 帮助中关于 TToolButton.AllowAllUp 属性的说明:

Indicates whether all the tool buttons in a group can be un-selected at the same time.

If AllowAllUp is set to true, all of the tool buttons in the group can be unselected. If AllowAllUp is set to false, at least one tool button in the group must be selected at any time. (Determine which tool button is initially selected by setting its Down property to true.)

AllowAllUp is effective only when Grouped is true and Style is set to tbsCheck. Changing the value of AllowAllUp for one button in a group automatically changes the value for all buttons in the group.

我所做的是在窗体上放置一个 TToolBar 并在其中创建三个 TToolButton。然后将AllowAllUp 和Grouped 属性设置为True。另外,将 Style 属性设置为 tbsCheck。

当我运行应用程序时,当我继续一一单击所有按钮时,任何一个按钮都会显示为选中状态,如果我尝试选择或单击其他 TToolButton,则前一个按钮将被取消选中。

如何使AllowAllUp属性起作用?

最佳答案

这些属性都按预期工作。您似乎误解了这些属性的意图。

Grouped 的文档属性说:

When an unbroken sequence of adjacent tool buttons each has its Grouped property set to true and Style set to tbsCheck, then no more than one of the buttons can be selected at the same time.

AllowAllUp属性是相关的并且描述如下:

Indicates whether all the tool buttons in a group can be unselected at the same time.

If AllowAllUp is set to true, all of the tool buttons in the group can be unselected. If AllowAllUp is set to false, at least one tool button in the group must be selected at any time. (Determine which tool button is initially selected by setting its Down property to true.)

AllowAllUp is effective only when Grouped is true and Style is set to tbsCheck. Changing the value of AllowAllUp for one button in a group automatically changes the value for all buttons in the group.

此属性仅在对按钮进行分组时才会产生影响,它的作用是控制是否可以按下零个按钮。但是,一旦您对按钮进行了分组,任何时候都不能按下一组以上的按钮。

您需要执行以下操作:

  • 分组设置为False
  • AllowAllUp 设置为 False,这并不重要,但您也可以恢复默认值以避免混淆。
  • 将样式设置为tbsCheck

完成此操作后,您可以独立地选中和取消选中这些按钮。

关于delphi - TToolButton 的AllowAllUp 属性不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35886798/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com