Programmatically select a ribbon command item from a ribbon split button

Programmatically select a ribbon command item from a ribbon split button

Anonymous
Not applicable
475 Views
1 Reply
Message 1 of 2

Programmatically select a ribbon command item from a ribbon split button

Anonymous
Not applicable

On a custom ribbon created programmatically with .net:  When a user runs a certain command, I want to change the selected/current (i.e. visible) ribbon command items on a ribbon split button. I cannot find any tool in the API for programmatically setting which of the command items shows as current, however. Hopefully, I'm just missing it and it's there.

 

I've tried IsVisible, IsChecked, and IsActive on the ribbon command item that I want to be shown as current, but none work. Here's my code (it's vb.net) in case it's helpful (note that I use linq to access the command item):

 

Dim rnbAppModeSplit As RibbonSplitButton = AcadRibbonService.GetRibbonSplitButton(rbnAppModePanel, RibbonKeys.AppModeSplitButtonId)
CType(rnbAppModeSplit.Items.ToList().Find(Function(x) x.Id = RibbonKeys.NotSelectedSplitListButtonId), RibbonCommandItem).IsVisible = True
CType(rnbAppModeSplit.Items.ToList().Find(Function(x) x.Id = RibbonKeys.NotSelectedSplitListButtonId), RibbonCommandItem).IsActive = True

CType(rnbAppModeSplit.Items.ToList().Find(Function(x) x.Id = RibbonKeys.NotSelectedSplitListButtonId), RibbonCommandItem).IsChecked = True

0 Likes
476 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

I literally solved this right after I pressed send.

 

I needed to set the current property of the split button to the item I wanted to be current/visible:

 

rnbAppModeSplit.Current = CType(rnbAppModeSplit.Items.ToList().Find(Function(x) x.Id = RibbonKeys.NotSelectedSplitListButtonId), RibbonCommandItem)

0 Likes