TToolButton 的 AllowAllUp 属性 不工作
AllowAllUp property for TToolButton Is Not Working
我正在使用 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。此外,将样式 属性 设置为 tbsCheck。
当我 运行 应用程序时,当我继续一个接一个地单击所有按钮时,任何一个按钮都显示为 selected,如果我尝试 select或单击其他 TToolButton,前一个变为未 selected。
如何使 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.
此 属性 仅在您对按钮进行分组时产生影响,它的作用是控制您是否可以按下零个按钮。但是一旦你对按钮进行了分组,在任何时候都不会有超过一个按钮被关闭。
您需要执行以下操作:
- 将
Grouped
设置为 False
。
- 将
AllowAllUp
设置为 False
,这并不重要,但您最好恢复默认值以避免混淆。
- 将样式设置为
tbsCheck
。
完成此操作后,您可以相互独立地选中和取消选中按钮。
我正在使用 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。此外,将样式 属性 设置为 tbsCheck。
当我 运行 应用程序时,当我继续一个接一个地单击所有按钮时,任何一个按钮都显示为 selected,如果我尝试 select或单击其他 TToolButton,前一个变为未 selected。
如何使 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.
此 属性 仅在您对按钮进行分组时产生影响,它的作用是控制您是否可以按下零个按钮。但是一旦你对按钮进行了分组,在任何时候都不会有超过一个按钮被关闭。
您需要执行以下操作:
- 将
Grouped
设置为False
。 - 将
AllowAllUp
设置为False
,这并不重要,但您最好恢复默认值以避免混淆。 - 将样式设置为
tbsCheck
。
完成此操作后,您可以相互独立地选中和取消选中按钮。