Message 1 of 4
How to Add a ribbon button with click mode pressed behavior in ribbon panel ( Ribbon item )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using the inventor APi and I would like to add a custom ribbon button (ribbon item ) to my ribbon Panel , once the user clicks on the button , it should be pressed , and when click on another button it should be pressed and the first button should be released.
How can I achieve this?
private void CreateButtonRibbonPanel(RibbonPanel ribbonPanel, List<CommadProperties> commandButtonPropList)
{
if (ribbonPanel != null && commandButtonPropList.Count > 0)
{
for (int i = 0; i < commandButtonPropList.Count; i++)
{
BtnIndex++;
commandButtonPropList[i].SetProperties();
CreateButtonToSamePanel(ribbonPanel.CommandControls, commandButtonPropList[i].CommandImage, commandButtonPropList[i].CommandName, commandButtonPropList[i].CommandClientId);
}
}
}
private void CreateButtonToSamePanel(CommandControls CmdCtrlsForOnePanel, string ImageName, string DisplayName, string ClientID)
{
if (m_CommandMgr == null || m_CtrlDefs == null || CmdCtrlsForOnePanel == null)
return;
stdole.IPictureDisp standardIconIPictureDisp = null;
if (ImageName.CompareTo("") != 0)
{
string Rooticon = Path.Combine(ResourcesDir, ImageName);
Bitmap standardbitmap = new Bitmap(Rooticon);
standardIconIPictureDisp = PictureDispConverter.ToIPictureDisp(standardbitmap);
}
else
{
standardIconIPictureDisp = null;
}
object vtAddInId = ClientID;
ButtonDef = null;
string InternalName = DisplayName + BtnIndex.ToString();
ButtonDef = m_CtrlDefs.AddButtonDefinition(DisplayName, InternalName, CommandTypesEnum.kQueryOnlyCmdType, vtAddInId, DisplayName, DisplayName,
standardIconIPictureDisp, standardIconIPictureDisp, ButtonDisplayEnum.kDisplayTextInLearningMode);
if (ButtonDef != null)
{
_ButtonDefEvents = new ButtonDefEvents(this, BtnIndex);
CommandControl CmdCtrl = CmdCtrlsForOnePanel.AddButton(ButtonDef, true, true, "", false);
if (CmdCtrl != null)
{
}
}
}