Hi,
I am working on a project and I'm running out of space for creating buttons in a custom tab. I want to create buttons in a dropdown so that after clicking the dropdown, the buttons become visible.
Please refer to the attached screenshot for more clarity.
I want to create similar buttons that are highlighted in the red block in the attached snap which should be visible after clicking the draw dropdown
A sample code would a great help
Thank you
Just look at the CUI editor and see how the Draw Panel is created. See the image below and note the types of controls that are used. There's a sub-panel, drop-down and Slide-out.
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
Thanks in advance!!!
The picture shows what you created, but is that what you want? Or are you still trying to create what is in the first post?
In lines 72 and 73, you simply add both vertical and horizontal controls to the RibbonSplitButton. In post 2, I showed you that the Home_Draw menu uses a SLIDEOUT, followed by two rows. In .NET this is the Autodesk.Windows.RibbonPanelBreak class. Add two rows to this container and then add buttons to each row container.
Sorry for the misunderstanding
I am still trying to create that I mentioned in the first post
A sample code related to the first post would be of a great help
Thankyou
Can't find what you're looking for? Ask the community or share your knowledge.