ShapeCollection.AddComboBox

ShapeCollection.AddComboBox method

Adds a ComboBox to the worksheet.

public ComboBox AddComboBox(int upperLeftRow, int top, int upperLeftColumn, int left, int height, 
    int width)
ParameterTypeDescription
upperLeftRowInt32Upper left row index.
topInt32Represents the vertical offset of ComboBox from its left row, in unit of pixel.
upperLeftColumnInt32Upper left column index.
leftInt32Represents the horizontal offset of ComboBox from its left column, in unit of pixel.
heightInt32Represents the height of ComboBox, in unit of pixel.
widthInt32Represents the width of ComboBox, in unit of pixel.

Return Value

A ComboBox object.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Drawing;

namespace AsposeCellsExamples
{
    public class ShapeCollectionMethodAddComboBoxWithInt32Int32Int32Int32Int32Int32Demo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Get the shapes collection
            ShapeCollection shapes = worksheet.Shapes;

            // Add a combo box with specified parameters
            Aspose.Cells.Drawing.ComboBox comboBox = shapes.AddComboBox(1, 0, 1, 0, 100, 50);

            // Add items to the combo box by setting cell values
            worksheet.Cells["A1"].PutValue("Item 1");
            worksheet.Cells["A2"].PutValue("Item 2");
            worksheet.Cells["A3"].PutValue("Item 3");

            // Set the input range for the combo box
            comboBox.InputRange = "A1:A3";
            comboBox.DropDownLines = 3;

            // Save the workbook
            workbook.Save("AddComboBoxDemo.xlsx");
        }
    }
}

See Also