How to add Items(object data type) to RibbonComboBox or RibbonDropDown in Ribbon Control?

May 31, 2012 at 1:45 PM

Hi All

I am developing a WindowsFormsApplication using Professional Ribbon Control. My requirement is to add Font names to Combobox control or to DropDownControl. I didn't get solution to this problem. 

Problem:

There is no Collection property or method to add Items to ComboBox Control as object data type.

DropDown Control has a Collection property with the name Items, but it is accepting only Ribbon Items. But the requirement is Adding object data type values to drop down control

My thought is :

If we develop a user control derived from RibbonItem class available in System.Windows.Forms.Ribbon namespace, we can add items to combobox control. Because, DropDown Control only accepting Ribbon Items. But I need to Add string items to the dropdown control.

 

Can any one help me ?

 

Thanks in advance

Kiran

Developer
Jun 1, 2012 at 3:05 AM
Edited Jun 1, 2012 at 3:08 AM

How about this?

public void AddItemsIntoComboBox()
{
    string[] stringArray = new string[] { "Red", "Green", "Blue" };

    int count = -1;

    ribbonComboBox1.DropDownItems.Clear();

    foreach (string s in stringArray)
    {
        count += 1;

        ribbonComboBox1.DropDownItems.Add(new RibbonButton());
        ribbonComboBox1.DropDownItems[count].Text = s;
    }
}
Jun 1, 2012 at 8:31 AM
Edited Jun 1, 2012 at 8:35 AM

Thank You adriancs,

 

It is working...

And

To get the selected value from ComboBox, I included some lines of code...modified the code..

 

RibbonComboBox rbnComboTest = new RibbonComboBox();
public void AddItemsIntoComboBox()
{ 
int count = -1;             
rbnComboTest.DropDownItems.Clear();             
RibbonButton RbnBtnTest = null;             
string[] stringArray = new string[] { "Red", "Green", "Blue" };         
foreach (string s in stringArray)            
{                
count += 1;                
RbnBtnTest = new RibbonButton();                
RbnBtnTest.Click += new EventHandler(RbnBtnTest_Click);
rbnComboTest.DropDownItems.Add(RbnBtnTest);                
rbnComboTest.DropDownItems[count].Text = s;          
}           
ribbon1.Tabs[1].Panels[0].Items.Add(rbnComboTest);}

void RbnBtnTest_Click(object sender, EventArgs e)

{

            rbnComboTest.TextBoxText = ((RibbonButton)sender).Text;

}

 

And moreover Can we provide ScrollBars to the Combobox Control?

 

Thanks & Regards,

Kiran

Developer
Jun 2, 2012 at 5:02 AM

I think scroll bar is not available for combobox at the moment. However, you can help out to fix it by joining the project.

The development of this project has been continued at here: http://officeribbon.codeplex.com/