DevExpress WinForms: Ribbon BarButtonGroup loses visual grouping when AllowAllUp = true is set for SpreadsheetControl alignment buttons

6 days ago 9
ARTICLE AD BOX

I am working with DevExpress WinForms SpreadsheetControl (v23.2) and generating a custom Ribbon. I have a SpreadsheetBarController linked to the control to automatically update the button states.

I want the horizontal alignment buttons (Left, Center, Right) to behave like Excel:

They must act as a mutually exclusive radio group (only 1 can be checked).

They can all be unchecked when the selected cell has "General" alignment.

They must visually look like a cohesive segmented control (merged borders inside the BarButtonGroup).

The Issue:To achieve mutual exclusivity and visually merged borders, I set the GroupIndex for all buttons in the group. However, GroupIndex forces at least one button to remain checked, which is incorrect for "General" cell alignment. To fix this, I added AllowAllUp = true. This fixes the logic (all buttons can be unchecked), but it breaks the visual style. The WXI skin stops rendering them as a segmented control and draws separate, disconnected borders for each button.

Here is the code I use to assign the GroupIndex and AllowAllUp properties to my generated alignment buttons:

private void SetupAlignmentButtons() { // horzCmds contains: "FormatAlignmentLeft", "FormatAlignmentCenter", "FormatAlignmentRight" var horzCmds = new List<string> { "FormatAlignmentLeft", "FormatAlignmentCenter", "FormatAlignmentRight" }; foreach (RibbonPageGroup group in ribbonPage1.Groups) { foreach (BarItemLink link in group.ItemLinks) { if (link.Item is BarButtonGroup btnGroup) { foreach (BarItemLink subLink in btnGroup.ItemLinks) { if (subLink.Item is DevExpress.XtraSpreadsheet.UI.SpreadsheetCommandBarButtonItem cmdBtn) { if (horzCmds.Contains(cmdBtn.CommandName)) { cmdBtn.GroupIndex = 202; cmdBtn.AllowAllUp = true; } } } } } } }

How can I maintain the joined/segmented visual appearance of the BarButtonGroup while allowing AllowAllUp = true so that the SpreadsheetBarController can uncheck all buttons when a cell has General alignment? Is there a specific property or workaround for the WXI skin?

Here what i hope:

Expected Visual Behavior

and What i stuck:

Actual Bugged Behavior

Read Entire Article