We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Databound comboBox

Next question in my eval... Do you have a solution for a databound combobox. I want the Items and values to come from a dataset not a collection.

Thank you

Kyle

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please first, insert your data inside your dataset in your desired rows and columns using the following method.

Import Data into Worksheet

Then bind your combo box to your inserted/imported data using the ComboBox.InputRange property.

Please see the following code example.

C#

//Create a new Workbook.  

Workbook workbook = new Workbook();

//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];

//Get the worksheet cells collection.
Cells cells = sheet.Cells;

//Input a value.
cells[“B3”].PutValue(“Employee:”);

//Set it bold.
cells[“B3”].Style.Font.IsBold = true;

//Input some values that denote the input range
//for the combo box.

cells[“A2”].PutValue(“Emp001”);

cells[“A3”].PutValue(“Emp002”);

cells[“A4”].PutValue(“Emp003”);

cells[“A5”].PutValue(“Emp004”);

cells[“A6”].PutValue(“Emp005”);

cells[“A7”].PutValue(“Emp006”);

//Add a new combo box.
Aspose.Cells.Drawing.ComboBox comboBox = sheet.Shapes.AddComboBox(2, 0, 2, 0, 22, 100);

//Set the linked cell;
comboBox.LinkedCell = “A1”;

//Set the input range.

comboBox.InputRange = “A2:A7”;

//Set no. of list lines displayed in the combo 

//box’s list portion.

comboBox.DropDownLines = 5;

//Set the combo box with 3-D shading.

comboBox.Shadow = true;

//AutoFit Columns

sheet.AutoFitColumns();

//Saves the file.

workbook.Save(@“d:\test\tstcombobox.xls”);

Please refer to this article for your complete help.

Managing Controls

Please see the subsection

Adding Combo Box Control to a Worksheet