.NET

Reply
Valued Contributor
FRPT1257
Posts: 69
Registered: ‎05-03-2006
Message 1 of 3 (110 Views)
Accepted Solution

RibbonButton side by side

110 Views, 2 Replies
07-20-2014 06:46 AM

I have the following code to create an RibbonButton.

 

This way buttons appeats side by side.

How can I put them in columns of 3 in each columns, followed verically and not just side by side horizontaly?

Autodesk.Windows.RibbonButton button = new RibbonButton();
button.Text = displayName;
button.Size = ribbonItemSize;
button.Orientation = System.Windows.Controls.Orientation.Horizontal;
button.Image = getBitmap(standardBitmap, 16, 16);
button.LargeImage = getBitmap(largeBitmap, 32, 32);
button.ShowText = showText;
button.CommandParameter = commandParameter;

 

Thanks & Regards,

Rui

Hey There,

 

How can I put them in columns of 3 in each columns, followed verically and not just side by side horizontaly?

 

Sorry I have not understood completely above statement ,nonetheless I have arranged button in 4X4 pattern on panel in other words two rows and two columns of buttons.

 

Do let me know if this doesn't help you.

 

[CommandMethod("SimpleButton")]
public void SimpleButton()
{
Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon;
RibbonTab Tab = new RibbonTab();
Tab.Title = "Test Ribbon";
Tab.Id = "TESTRIBBON_TAB_ID";
ribbonControl.Tabs.Add(Tab);
Autodesk.Windows.RibbonPanelSource srcPanel = new RibbonPanelSource();
srcPanel.Title = "Panel1";
srcPanel.Id = "PANEL_1_ID";
RibbonPanel Panel = new RibbonPanel();
Panel.Source = srcPanel;
Tab.Panels.Add(Panel);
/*Create Button 1*/
Autodesk.Windows.RibbonButton button1 = new RibbonButton();
button1.Text = "Button1";
button1.Size = RibbonItemSize.Large;
/*
Embedding Image resource to your project
1.On the Project menu, choose Add Existing Item.
2.Navigate to the image you want to add to your project. Click the Open button to add the image to your project's file list.
3.Right-click the image in your project's file list and choose Properties. The Properties window appears.
4.Find the Build Action property in the Properties window. Change its value to Embedded Resource.
*
Then opens a stream on the embedded image. The name used to refer to the image takes this form:
<namespace>.<image name>.<format> */
button1.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button1.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button1.ShowText = true;
/*Create Button 2*/
Autodesk.Windows.RibbonButton button2 = new RibbonButton();
button2.Text = "Button2";
button2.ShowText = true;
button2.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button2.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button2.Size = RibbonItemSize.Large;
Tab.IsActive = true;
/*Create Button 3*/
Autodesk.Windows.RibbonButton button3 = new RibbonButton();
button3.Text = "Button3";
button3.ShowText = true;
button3.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button3.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button3.Size = RibbonItemSize.Large;
Tab.IsActive = true;
/*Create Button 4*/
Autodesk.Windows.RibbonButton button4 = new RibbonButton();
button4.Text = "Button4";
button4.ShowText = true;
button4.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button4.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button4.Size = RibbonItemSize.Large;
Tab.IsActive = true;
Autodesk.Windows.RibbonRowPanel ribRowPanel1 = new RibbonRowPanel();
ribRowPanel1.Items.Add(button1);
ribRowPanel1.Items.Add(new RibbonRowBreak());
ribRowPanel1.Items.Add(button2);
srcPanel.Items.Add(ribRowPanel1);
RibbonSeparator rsP = new RibbonSeparator();
rsP.SeparatorStyle = RibbonSeparatorStyle.Invisible;
srcPanel.Items.Add(rsP);
Autodesk.Windows.RibbonRowPanel ribRowPanel2 = new RibbonRowPanel();
ribRowPanel2.Items.Add(button3);
ribRowPanel2.Items.Add(new RibbonRowBreak());
ribRowPanel2.Items.Add(button4);
srcPanel.Items.Add(ribRowPanel2);
}
public BitmapImage LoadImage(string imageName, int Height, int Width)
{
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageName);
// image.UriSource = new Uri(imageName);
image.DecodePixelHeight = Height;
image.DecodePixelWidth = Width;
image.EndInit();
return image;
}

 

ADN Support Specialist
madhukar.moogala
Posts: 67
Registered: ‎01-28-2014
Message 2 of 3 (76 Views)

Re: RibbonButton side by side

07-22-2014 04:48 AM in reply to: FRPT1257

Hey There,

 

How can I put them in columns of 3 in each columns, followed verically and not just side by side horizontaly?

 

Sorry I have not understood completely above statement ,nonetheless I have arranged button in 4X4 pattern on panel in other words two rows and two columns of buttons.

 

Do let me know if this doesn't help you.

 

[CommandMethod("SimpleButton")]
public void SimpleButton()
{
Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon;

RibbonTab Tab = new RibbonTab();
Tab.Title = "Test Ribbon";
Tab.Id = "TESTRIBBON_TAB_ID";

ribbonControl.Tabs.Add(Tab);

Autodesk.Windows.RibbonPanelSource srcPanel = new RibbonPanelSource();
srcPanel.Title = "Panel1";
srcPanel.Id = "PANEL_1_ID";

RibbonPanel Panel = new RibbonPanel();
Panel.Source = srcPanel;
Tab.Panels.Add(Panel);
/*Create Button 1*/
Autodesk.Windows.RibbonButton button1 = new RibbonButton();
button1.Text = "Button1";
button1.Size = RibbonItemSize.Large;
/*
Embedding Image resource to your project
1.On the Project menu, choose Add Existing Item.
2.Navigate to the image you want to add to your project. Click the Open button to add the image to your project's file list.
3.Right-click the image in your project's file list and choose Properties. The Properties window appears.
4.Find the Build Action property in the Properties window. Change its value to Embedded Resource.
*
Then opens a stream on the embedded image. The name used to refer to the image takes this form:
<namespace>.<image name>.<format>  */
button1.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button1.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button1.ShowText = true;
                    
/*Create Button 2*/
            
Autodesk.Windows.RibbonButton button2 = new RibbonButton();
button2.Text = "Button2";
button2.ShowText = true;
button2.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button2.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button2.Size = RibbonItemSize.Large;
Tab.IsActive = true;

/*Create Button 3*/
Autodesk.Windows.RibbonButton button3 = new RibbonButton();
button3.Text = "Button3";
button3.ShowText = true;
button3.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button3.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button3.Size = RibbonItemSize.Large;
Tab.IsActive = true;

/*Create Button 4*/
Autodesk.Windows.RibbonButton button4 = new RibbonButton();
button4.Text = "Button4";
button4.ShowText = true;
button4.Image = LoadImage("TestSharp2015.Koala.jpg", 16, 16);
button4.LargeImage = LoadImage("TestSharp2015.Koala.jpg", 32, 32);
button4.Size = RibbonItemSize.Large;
Tab.IsActive = true;

Autodesk.Windows.RibbonRowPanel ribRowPanel1 = new RibbonRowPanel();
ribRowPanel1.Items.Add(button1);
ribRowPanel1.Items.Add(new RibbonRowBreak());
ribRowPanel1.Items.Add(button2);
srcPanel.Items.Add(ribRowPanel1);
RibbonSeparator rsP = new RibbonSeparator();
rsP.SeparatorStyle = RibbonSeparatorStyle.Invisible;
srcPanel.Items.Add(rsP);
Autodesk.Windows.RibbonRowPanel ribRowPanel2 = new RibbonRowPanel();
ribRowPanel2.Items.Add(button3);
ribRowPanel2.Items.Add(new RibbonRowBreak());
ribRowPanel2.Items.Add(button4);
srcPanel.Items.Add(ribRowPanel2);
                      
}

public BitmapImage LoadImage(string imageName, int Height, int Width)
{
BitmapImage image = new BitmapImage();

image.BeginInit();
image.StreamSource = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageName);
// image.UriSource = new Uri(imageName);
image.DecodePixelHeight = Height;
image.DecodePixelWidth = Width;
image.EndInit();
return image;
}

 

ADN Support Specialist
Valued Contributor
FRPT1257
Posts: 69
Registered: ‎05-03-2006
Message 3 of 3 (65 Views)

Re: RibbonButton side by side

07-22-2014 08:31 AM in reply to: madhukar.moogala
Great!! :smileyhappy:

I was missing the "new RibbonRowBreak()"

Thanks
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.