I am using Delphi XE5.
I am trying to workout as per the Delphi's help about TToolButton component.
Delphi Help Says about TToolButton.AllowAllUp property:
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.
What I have done is I have placed a TToolBar on the form and created three TToolButtons in it. Then AllowAllUp and Grouped property is set to True. Also, set Style property to tbsCheck.
When I run the application, and when I go on clicking all buttons one by one, then any one button is showing as selected, if i try to select or click on other TToolButton previous one becomes un-selected.
How to make AllowAllUp property working?
These properties all work as intended. It seems that you are misunderstanding the intent of these properties.
The documentation for the Grouped property says:
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.
The AllowAllUp property is related and described like so:
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.
This property only has an impact when you group buttons, and what it does is control whether or not you can have zero buttons down. But once you have grouped buttons, never more than one of the group can be down at any one time.
You need to do the following:
Set Grouped to False.
Set AllowAllUp to False, not that it really matters but you may as well restore the default to avoid confusion.
Set the style to tbsCheck.
Once you've done this you can check and uncheck the buttons independently of each other.
Related
I have three menu items I would like to toggle between one another with a check.
The first one is default checked = true and the other two are false
I would like to have the check mark show next to the one clicked
I tried setting the group index of the three different from the rest of all the other menu items, but that didn't seem to work. All three menu items have autocheck = true
do I have to manually handle all this by code?
thanx
You need to do the following for each of the three menu items:
Set AutoCheck to True.
Set RadioItem to True.
Set the GroupIndex for all three items to the same value.
This will result in a bullet rather than a tick being placed next to your menu item. That's by design. These menu items operate like radio buttons (hence the bullet) rather than check boxes (which would have ticks).
The help indicates that adding gboGroupStyle to the ButtonOptions on a TButtonGroup:
"Specifies that the buttons should inherit the group style that is set on the container."
But this explanation still leaves me lost - any ideas?
The gboGroupStyle option in the TButtonGroup.ButtonOptions property has nothing to do with GroupIndex as it's known e.g. from TSpeedButton.
Setting of the gboGroupStyle option to True allows you to:
set the TButtonGroup.ItemIndex property, so you can predefine which button will be focused as default, nothing cool
click the buttons with ENTER or SPACE keys, what will fire the TGrpButtonItem.OnClick event of the button item (if assigned), perform its action, or fire the TButtonGroup.OnButtonClicked event
I agree the name of this is quite misleading, but that's what I found in the source code from Delphi-XE2.
gboGroupStyle makes the TButtonGroup act as a group - that means, one and only one button is selected at a given time. It is similar to grouping several TSpeedButtons with the GroupIndex, where only one button inside that group is selected at any time. The currently selected button can be read and written via the ItemIndex property of TButtonGroup. To visualize the selected button one can implement an OnBeforeDrawButton or OnDrawButton handler.
From my experimentation it looks like if gboGroupStyle is used then the ItemIndex property can be set to something other than -1, so that the TButtonGroup remembers the last button that was pressed.
The selected row of a tListView appears blue, but only when the control has focus. I'd like the selected row to always be displayed, whether the control has focus or not.
Set the HideSelection property to False.
Determines whether the list view gives a visual indication of which item is selected when focus shifts to another control.
Set HideSelection to false to provide visual feedback of the selected item in the list even when the list view does not have focus. Set HideSelection to true to show the selection only when the list view has focus. HideSelection does not affect the actual value of the selection, only the visual indication. Always setting HideSelection to false can make forms with many list views look too busy.
One small question. I need to have my selected treeview item stay visually "selected" even when focus is set on other component, anybody knows which property is responsible for that?
The property you are looking for is called
HideSelection
From the help:
Use HideSelection to specify whether
the user is given visual feedback
about the current selection in the
tree view when it does not have focus.
If true, the selected node is not
visually distinct from other nodes
until focus returns to the control. If
false, the node always appears
selected.
I created 3 actions and assigned them to 3 buttons in a ribbon group. I want the buttons act like a group, one is always down, the others - up. Just like left/center/right align buttons.
I have set groupIndex property of my actions to 1. Help says:
"GroupIndex is used to define groups of actions that act like radio buttons. When GroupIndex is greater than 0, it identifies the group to which the action belongs. When the Checked property of any action in that group is set to true, the Checked property of all other actions in the group is set to false. That is, only one action in the group can be checked at a time."
But it is not working at all.
Any help?
Try to set the property AutoCheck = true for both items. It helped me =)
Without more information the only thing I can suggest is (if you are using tdxRibbon) is to check and make sure the buttonstyle property is set to bsChecked. Although it shouldn't let you set the group index otherwise.