I am using this sample code
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
using System;
[assembly: CommandClass(typeof(MyRibbonApp.MyCommands))]
namespace MyRibbonApp
{
public class MyCommands : IExtensionApplication
{
public void Initialize()
{
CreateRibbonPanel();
}
public void Terminate()
{
}
private void CreateRibbonPanel()
{
RibbonControl ribbonControl = ComponentManager.Ribbon;
if (ribbonControl != null)
{
RibbonTab ribbonTab = ribbonControl.FindTab("CustomTab");
if (ribbonTab == null)
{
ribbonTab = new RibbonTab
{
Title = "Custom Tab",
Id = "CustomTab"
};
ribbonControl.Tabs.Add(ribbonTab);
}
RibbonPanelSource panelSource = new RibbonPanelSource
{
Title = "Custom Panel"
};
RibbonPanel ribbonPanel = new RibbonPanel
{
Source = panelSource
};
ribbonTab.Panels.Add(ribbonPanel);
// Create the dropdown button named "Earthing Layout"
RibbonSplitButton earthingLayoutDropdown = new RibbonSplitButton
{
Text = "Earthing Layout",
ShowText = true
};
// Create individual buttons
RibbonButton verticalStripButton = new RibbonButton
{
Text = "Vertical Strip",
CommandParameter = "VerticalStripCommand",
CommandHandler = new RibbonCommandHandler()
};
RibbonButton horizontalStripButton = new RibbonButton
{
Text = "Horizontal Strip",
CommandParameter = "HorizontalStripCommand",
CommandHandler = new RibbonCommandHandler()
};
// Add buttons to the dropdown
earthingLayoutDropdown.Items.Add(verticalStripButton);
earthingLayoutDropdown.Items.Add(horizontalStripButton);
// Add the dropdown to the panel
panelSource.Items.Add(earthingLayoutDropdown);
}
}
}
public class RibbonCommandHandler : System.Windows.Input.ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
string command = parameter as string;
if (!string.IsNullOrEmpty(command))
{
Application.DocumentManager.MdiActiveDocument.SendStringToExecute(command + " ", true, false, true);
}
}
}
}
I want to create a main button named "Earthing" and then this button should contain the dropdown and this dropdown should contain two more buttons name "Vertical strip" and "Horizontal strip"
but instead of "Earthing" button, there is again a "Vertical strip" button
What modifications should I make in attached code
refer the attached snap for better clarity
![swapnil_lokam_0-1722519790006.png swapnil_lokam_0-1722519790006.png](https://forums.autodesk.com/t5/image/serverpage/image-id/1393376iDF460D6E41FEC8CD/image-size/medium?v=v2&px=400)
Thanks in advance!!!