Interface IComboBoxShape
This interface provides access to the combo box shape properties.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IComboBoxShape : IShape, IParentApplication
Properties
Display3DShading
Gets or sets value indicating whether 3D shadow is present.
Declaration
bool Display3DShading { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
The following code illustrates how to set Display3DShading
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
worksheet["J4"].Value = "4";
worksheet["J5"].Value = "5";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J5"];
//Set selected index
combobox.SelectedIndex = 1;
//Set 3D shading
combobox.Display3DShading = true;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
DropDownLines
Gets or sets the number of list lines displayed in the drop-down portion of a combo box.
Declaration
int DropDownLines { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set DropDownLines
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
worksheet["J4"].Value = "4";
worksheet["J5"].Value = "5";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J5"];
//Set selected index
combobox.SelectedIndex = 1;
//Set droplines
combobox.DropDownLines = 2;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
LinkedCell
Gets or sets the worksheet range linked to the control's value.
Declaration
IRange LinkedCell { get; set; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to set LinkedCell
to display the SelectedValue of combobox.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J3"];
//Set linked cell
combobox.LinkedCell = worksheet["D2"];
//Set selected index
combobox.SelectedIndex = 2;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
ListFillRange
Gets or sets the worksheet range used to fill the specified list box.
Declaration
IRange ListFillRange { get; set; }
Property Value
Type |
---|
IRange |
Examples
The following code illustrates how to set the ListFillRange
to load the data for the combobox.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J3"];
//Set linked cell
combobox.LinkedCell = worksheet["D2"];
//Set selected index
combobox.SelectedIndex = 2;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
SelectedIndex
Gets or sets selected item index of the combo box.
Declaration
int SelectedIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to set the SelectedIndex
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J3"];
//Set linked cell
combobox.LinkedCell = worksheet["D2"];
//Set selected index
combobox.SelectedIndex = 2;
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
SelectedValue
Gets value selected in combobox.
Declaration
string SelectedValue { get; }
Property Value
Type |
---|
System.String |
Remarks
1-based indexing is used to access the values in combobox list.
Examples
The following code illustrates how to access SelectedValue
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Load data
worksheet["J1"].Value = "1";
worksheet["J2"].Value = "2";
worksheet["J3"].Value = "3";
//Add combobox
IComboBoxShape combobox = worksheet.ComboBoxes.AddComboBox(2, 2, 20, 100);
//Add combobox data
combobox.ListFillRange = worksheet["J1:J3"];
//Set selected index
combobox.SelectedIndex = 1;
//Get selected value
Console.Write(combobox.SelectedValue);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//1