All,

I am having troubles accessing the values of my embedded controls within a spreadsheet. Each row (there are a variable number of rows depending on what's downloaded from the datasource) is programmatically populated with a checkbox and combobox. The combobox's are named comboBox + i, where i is an integer assigned in a for loop. I have no problem populating the controls using the following code but am unable to retrieve the values when I click on an embedded button (The button click event works quite well and I can retrieve individual cell values no problem):

for (int i=0; i<someVariableInteger; i++)
{
Microsoft.Office.Tools.Excel.Controls.ComboBox comboBox1 = this.Controls.AddComboBox(this.Range["C"+(i+7), missing], "comboBox"+i);
comboBox1.Items.Add(""); //index 0
comboBox1.Items.Add("blah"); //index 1
comboBox1.Items.Add("blah blah"); //index 2
comboBox1.SelectedIndex = 0;
}

My understanding of this code is that comboBox1 is overwritten everytime I iterate through the loop while the name assigned (comboBox+i) in the AddComboBox method is the name I would use to access the value.

Again, all of this works famously and I end up with approximately 109 rows with comboboxes that have a unique name (I assume).

I have no idea how to retrieve the selected value in the combobox.

Anyone out there solved this problem already? Any help would be very much appreciated.

I am using c# with .Net 2.0, Excel 2003, Visual Studio 2005, and Visual Studio Tools for Office 2005.

Thank you in advance,
Kevin