![]() |
CommandBarButton Width |
Post Reply ![]() |
Author | |
apuhjee ![]() Senior Member ![]() ![]() Joined: 02 September 2005 Location: United States Status: Offline Points: 130 |
![]() ![]() ![]() ![]() ![]() Posted: 26 June 2007 at 5:25pm |
At what point is the Width of a RibbonBar button known? I'm trying to add three "state" buttons and set them all to be the same size as the widest... but the width = 0 immediately after they have been added to a group.
Thanks ~ jp
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, Show code you tried.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
apuhjee ![]() Senior Member ![]() ![]() Joined: 02 September 2005 Location: United States Status: Offline Points: 130 |
![]() ![]() ![]() ![]() ![]() |
This is what it looks like by default:
![]() This is what I'm going for:
![]() Notice the watch value:
![]() And here is the code I'm using. Note: it looks ok if I uncomment the explicit width values of 60... but I'd rather not assume that the font metrics will always be the same as they are on my dev machine
![]() private static void ConfigureViewTag() { RibbonTab tabView = AddTab(ID.ID_TAB_VIEW, "View"); RibbonGroup groupPanes = AddGroup(tabView.Id, ID.ID_GROUP_PANES, "Panes", false, null); viewObjectExplorerPane = AddControl(groupPanes.Id, "VIEW_OBJECT_EXPLORER_PANE", XTPControlType.xtpControlButton, "Object Explorer", "Show/Hide the Object Explorer Pane", "ToggleObjectExplorerPaneAction"); CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "object_explorer.ico"), viewObjectExplorerPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal); viewPropertiesPane = AddControl(groupPanes.Id, "VIEW_PROPERTIES_PANE", XTPControlType.xtpControlButton, "Properties", "Show/Hide the Properties Pane", "TogglePropertiesPaneAction"); CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "properties.ico"), viewPropertiesPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal); viewCalendarPane = AddControl(groupPanes.Id, "VIEW_CALENDAR_PANE", XTPControlType.xtpControlButton, "Calendar", "Show/Hide the Calendar Pane", "ToggleCalendarPaneAction"); CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "calendar.ico"), viewCalendarPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal); SetEqualButtonWidth(groupPanes); //viewObjectExplorerPane.Width = 60; //viewPropertiesPane.Width = 60; //viewCalendarPane.Width = 60; } public static void SetEqualButtonWidth(RibbonGroup group) { int maxWidth = 0; foreach (CommandBarControl control in group) { if (control.Width > maxWidth) maxWidth = control.Width; } foreach (CommandBarControl control in group) { control.Width = maxWidth; } } public static CommandBarControl AddControl(int groupId, string resourceName, XTPControlType controlType, string controlCaption, string controlDescription, string actionMethod) { RibbonGroup group = RibbonBar.FindGroup(groupId); int resourceId = ResourceManager.AddResource(resourceName); CommandBarControl control = group.Add(controlType, resourceId, controlCaption, false, false); control.Action.Tag = actionMethod; CommandBars.Actions.Add(resourceId, controlCaption, controlCaption, controlDescription, group.Caption); return control; } |
|
![]() |
|
apuhjee ![]() Senior Member ![]() ![]() Joined: 02 September 2005 Location: United States Status: Offline Points: 130 |
![]() ![]() ![]() ![]() ![]() |
While we're on the topic (sort of...), it would be extremely awesome if you guys would make a true state button rather than require the use of the Checked property.
It may not have been a problem in the past, but with the animation in the Ribbon Bar, the short time between the user click and setting the Button.Checked property looks a little strange.
But I'm a perfectionist.
![]() |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Before it become visible Width will be 0. you can set Width parameter to some predefined value.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
apuhjee ![]() Senior Member ![]() ![]() Joined: 02 September 2005 Location: United States Status: Offline Points: 130 |
![]() ![]() ![]() ![]() ![]() |
Very interesting. So I have to display it to the user first - then change its visual appearance.
![]() |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |