CheckBox and ToggleButton - harborsiem/WinForms-Ribbon GitHub Wiki
In short, I’ve added support for CheckBox and ToggleButton ribbon controls. A new sample, named “10-CheckBox” has been added to the project site. The result look like this:
Using CheckBox and ToggleButton – Ribbon Markup
Commands and Views sections:
<?xml version='1.0' encoding='utf-8'?>
<Application xmlns='http://schemas.microsoft.com/windows/2009/Ribbon'>
<Application.Commands>
<Command Name="cmdToggleButton"
Id="1002"
LabelTitle="Toggle Button">
<Command.LargeImages>
<Image>Res/Open32.bmp</Image>
</Command.LargeImages>
<Command.SmallImages>
<Image>Res/Open16.bmp</Image>
</Command.SmallImages>
</Command>
<Command Name="cmdCheckBox"
Id="1003"
LabelTitle="Check Box">
<Command.LargeImages>
<Image>Res/Save32.bmp</Image>
</Command.LargeImages>
<Command.SmallImages>
<Image>Res/Save16.bmp</Image>
</Command.SmallImages>
</Command>
</Application.Commands>
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab>
<Group>
<ToggleButton CommandName="cmdToggleButton" />
</Group>
<Group CommandName="cmdGroupCheckBox">
<CheckBox CommandName="cmdCheckBox" />
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
</Application>
Using CheckBox and ToggleButton – Code Behind
Initializing:
partial class RibbonItems
{
public void Init()
{
Button.Click += new EventHandler<EventArgs>(_button_ExecuteEvent);
}
}
Get / Set CheckBox status:
void _button_ExecuteEvent(object sender, EventArgs e)
{
MessageBox.Show("RibbonCheckBox check status is: " + CheckBox.BooleanValue.ToString());
}