title: Dynamically populate a ribbon design combobox with a string array?
body: <p>I'm wondering how to dynamically populate a combobox in the Ribbon Designer for an excel 2010 Add-in. I have a button that when pressed calls a method that finds a list of all available SQL Servers on the network. I then want to show all the SQL servers that the method found and populate the Combo-box. I have been able to populate the combo-box with the datasource property in a Windows Forms Application, but in the ribbon designer it is missing some of those properties. </p>
  
  <p>I was wondering if there was a way to do it with <code>comboBox1.Items.Add(string[] array here)</code>
  But it appears that the comboBox1.Items.Add takes object, so I was wondering if there was a way to make each string in the array into an object with a for loop.</p>
  
  <p>I also heard that another possible solution could be to use the XML Ribbon Designer, but I'm not to comfortable with that just yet. I've done a ton of research on it, and haven't been able to find anything that fit my exact situation. Thank-you in advance, here is some of my code.</p>
  
  <pre><code>public static string[] GetSQLServerList()
  {
  SqlDataSourceEnumerator dse = SqlDataSourceEnumerator.Instance;
  DataTable dt = dse.GetDataSources();
  if (dt.Rows.Count == 0)
  {
        return null;
  }
  
  string[] SQLServers = new string[dt.Rows.Count];
  int f = -1;
  foreach (DataRow r in dt.Rows)
      {
         string SQLServer = r["ServerName"].ToString();
         string Instance = r["InstanceName"].ToString();
         if (Instance != null &amp;&amp; !string.IsNullOrEmpty(Instance))
            {
               int i = 0;SQLServer += "\\" + Instance;
            }
         SQLServers[System.Math.Max(System.Threading.Interlocked.Increment(ref f), f - 1)] = SQLServer;
      }
   Array.Sort(SQLServers);
  
   //not sure how to fill combobox from here
   comboBox1.Items.Add(RibbonDropDownItem here);
   return SQLServers;
  
   }
  </code></pre>
  
  <p>In my Windows Forms Application I have the exact same method, and this is how I populate the combo-box.</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
          Cursor = Cursors.WaitCursor;
          comboBox1.DataSource = GetSQLServerList();
          Cursor = Cursors.Default;
      }
  </code></pre>
  
  <p>But like I said before, there is no Datasource property in the Ribbon Visual Designer.</p>
  
  <pre><code>  ![ribbon designer combobox properties][1]
    [1]: http://i.stack.imgur.com/xzNUO.png
  </code></pre>
  
  <p>So, I think Basically, in the excel 2010 add-in, there will be a button that populates the combobox with the SQL servers on the network. Then the user can choose from the combo-box which server they want to connect to. All I need to be able to do from there is get the selected option from the combobox and I'm set. Thanks so much in advance!</p>