Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I modify the items of SplitButton?

5 REPLIES 5
Reply
Message 1 of 6
abdechafi.neji
244 Views, 5 Replies

How can I modify the items of SplitButton?

Suppose that I've this line of code that can add a split button , I would like to know if there is a possibility to modify the items of this SplitButton created later ( without delete it and create new one ) .

 

RibbonSplit = ribbonPanel.CommandControls.AddSplitButton(buttonList[0], objectcollect, IsLargeIcon);

 

 

Tags (1)
Labels (3)
5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: abdechafi.neji

After quickly reviewing the online help documentation, it looks like the CommandControl.ChildControls (a CommandControls Object) is ReadOnly, which just means you can't directly set another CommandControls object as its value, not that you can't modify items within it.  So, once you get that collection, it looks like you can use its available methods to easily add another CommandControl to it, or use its Item() property to specify an existing CommandControl object, then use its Delete method.  It says that Delete method will simply remove that control from the panel, not delete it from the system.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

May you please give me a simple method that can do this ? I mean a custom method ( delete without deleting from system + create)

Message 4 of 6
WCrihfield
in reply to: abdechafi.neji

I don't have any already existing example codes like this, but the methods are basically built into the objects themselves.  Below is a quickie code example, where I have declared the variables involved, but haven't actually assigned real values to them, other than the one for the split button.  I have an example of how to add another button under the split button, and an example of how to remove a button that already exists under the split button.

Dim oRibbonPanel As RibbonPanel '= .....
Dim oDefaultButtonDef As ButtonDefinition '= ........
Dim oOtherButtonDefs As ObjectCollection '= .........
Dim oSplitButton1 As CommandControl
oSplitButton1 = oRibbonPanel.CommandControls.AddSplitButton(oDefaultButtonDef, oOtherButtonDefs, False, True)

'how to add a button within the split button:
'first get the button's definition that you want to add under the split button
Dim oBtnDef As ButtonDefinition '= .......
'now add that under the split buttton like this
oSplitButton1.ChildControls.AddButton(oBtnDef)

'how to remove a button from within the split button:
oSplitButton1.ChildControls.Item("CommandControlName").Delete
'again, this just removed the CommandControl object (user interface object),
'and does not actually delete the ControlDefinition that defines the command that it would execute

RibbonPanel 

RibbonPanel.CommandControls 

CommandControls.AddSplitButton 

CommandControl 

CommandControl.ChildControls 

CommandControls.AddButton 

CommandControl.Delete 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

Thank you , but what about the Id of the buttons under the SplitButton ??

Message 6 of 6
WCrihfield
in reply to: abdechafi.neji

I'm not sure I understand the question, but I think by Id you mean either the Index integer, DisplayName, or InternalName of the CommandControl objects under the split button.  I suspect that you are not sure which which ones are at which indexes, or what the DisplayName or InternalName of those existing controls may be, so that you can specify one to delete.  In that case, I would probably create a 'New List(Of String)' type variable, then loop through the Items within the ChildControls, and add the InternalName of each CommandControl to that list.  Then use something like:  oChosenControlName = InputListBox(sPrompt, oControlNamesList) to help you select one of their names.  Then use that chosen control name in the ChildControls.Item(oChosenControlName).Delete.  Does that sound like a plan you could work with?

Dim oSplitButton1 As CommandControl '= .....
Dim oControlNamesList As New List(Of String)
For Each oCC As CommandControl In oSplitButton1.ChildControls
	oControlNamesList.Add(oCC.InternalName)
Next
Dim oChosenControlName As String = InputListBox("Choose a control internal name.", oControlNamesList)
oSplitButton1.ChildControls.Item(oChosenControlName).Delete

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report