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);
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
(Not an Autodesk Employee)
May you please give me a simple method that can do this ? I mean a custom method ( delete without deleting from system + create)
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
CommandControls.AddSplitButton
Wesley Crihfield
(Not an Autodesk Employee)
Thank you , but what about the Id of the buttons under the SplitButton ??
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
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.