Class ListBox

Class ListBox

Namespace: Aspose.Cells.Drawing
Assembly: Aspose.Cells.dll (25.2.0)

Represents a list box object.

public class ListBox : Shape

Inheritance

objectShapeListBox

Inherited Members

Shape.GetResultOfSmartArt(), Shape.ToFrontOrBack(int), Shape.GetLockedProperty(ShapeLockType), Shape.SetLockedProperty(ShapeLockType, bool), Shape.AddHyperlink(string), Shape.RemoveHyperlink(), Shape.MoveToRange(int, int, int, int), Shape.AlignTopRightCorner(int, int), Shape.GetConnectionPoints(), Shape.ToImage(Stream, ImageType), Shape.ToImage(string, ImageOrPrintOptions), Shape.ToImage(Stream, ImageOrPrintOptions), Shape.GetLinkedCell(bool, bool), Shape.SetLinkedCell(string, bool, bool), Shape.GetInputRange(bool, bool), Shape.SetInputRange(string, bool, bool), Shape.UpdateSelectedValue(), Shape.CalculateTextSize(), Shape.FormatCharacters(int, int, Font, StyleFlag), Shape.Characters(int, int), Shape.GetRichFormattings(), Shape.RemoveActiveXControl(), Shape.IsSameSetting(object), Shape.GetActualBox(), Shape.MacroName, Shape.IsEquation, Shape.IsSmartArt, Shape.ZOrderPosition, Shape.Name, Shape.AlternativeText, Shape.Title, Shape.Line, Shape.Fill, Shape.ShadowEffect, Shape.Reflection, Shape.Glow, Shape.SoftEdges, Shape.ThreeDFormat, Shape.FormatPicture, Shape.IsHidden, Shape.IsAspectRatioLocked, Shape.RotationAngle, Shape.Hyperlink, Shape.Id, Shape.Spid, Shape.Spt, Shape.Worksheet, Shape.IsGroup, Shape.IsInGroup, Shape.IsWordArt, Shape.TextEffect, Shape.IsLocked, Shape.IsPrintable, Shape.MsoDrawingType, Shape.AutoShapeType, Shape.AnchorType, Shape.Placement, Shape.UpperLeftRow, Shape.UpperDeltaY, Shape.UpperLeftColumn, Shape.UpperDeltaX, Shape.LowerRightRow, Shape.LowerDeltaY, Shape.LowerRightColumn, Shape.LowerDeltaX, Shape.Right, Shape.Bottom, Shape.Width, Shape.WidthInch, Shape.WidthPt, Shape.WidthCM, Shape.Height, Shape.HeightInch, Shape.HeightPt, Shape.HeightCM, Shape.Left, Shape.LeftInch, Shape.LeftCM, Shape.Top, Shape.TopInch, Shape.TopCM, Shape.TopToCorner, Shape.LeftToCorner, Shape.X, Shape.Y, Shape.WidthScale, Shape.HeightScale, Shape.TopInShape, Shape.LeftInShape, Shape.WidthInShape, Shape.HeightInShape, Shape.Group, Shape.Type, Shape.HasLine, Shape.IsFilled, Shape.IsFlippedHorizontally, Shape.IsFlippedVertically, Shape.ActualLowerRightRow, Shape.RelativeToOriginalPictureSize, Shape.LinkedCell, Shape.InputRange, Shape.TextShapeType, Shape.TextBody, Shape.Font, Shape.TextOptions, Shape.Text, Shape.IsRichText, Shape.HtmlText, Shape.TextVerticalOverflow, Shape.TextHorizontalOverflow, Shape.IsTextWrapped, Shape.TextOrientationType, Shape.TextHorizontalAlignment, Shape.TextVerticalAlignment, Shape.TextDirection, Shape.TextBoxOptions, Shape.ControlData, Shape.ActiveXControl, Shape.Paths, Shape.Geometry, Shape.CreateId, Shape.IsDecorative, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

csharp
[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("Choose Dept:");

//Set it bold.
Style style = cells["B3"].GetStyle();
style.Font.IsBold = true;
cells["B3"].SetStyle(style);

//Input some values that denote the input range
//for the list box.
cells["A2"].PutValue("Sales");
cells["A3"].PutValue("Finance");
cells["A4"].PutValue("MIS");
cells["A5"].PutValue("R&D");
cells["A6"].PutValue("Marketing");
cells["A7"].PutValue("HRA");

//Add a new list box.
ListBox listBox = sheet.Shapes.AddListBox(2, 0, 3, 0, 122, 100);

//Set the placement type.
listBox.Placement = PlacementType.FreeFloating;

//Set the linked cell.
listBox.LinkedCell = "A1";

//Set the input range.
listBox.InputRange = "A2:A7";

//Set the selection style.
listBox.SelectionType = SelectionType.Single;

//Set the list box with 3-D shading.
listBox.Shadow = true;

//Saves the file.
workbook.Save(@"tstlistbox.xls");

'Create a new Workbook.
Dim workbook As Aspose.Cells.Workbook = New Aspose.Cells.Workbook()

'Get the first worksheet.
Dim sheet As Worksheet = workbook.Worksheets(0)

'Get the worksheet cells collection.
Dim cells As Cells = sheet.Cells

'Input a value.
cells("B3").PutValue("Choose Dept:")

'Set it bold.
Dim style As Style = cells("B3").GetStyle()
style.Font.IsBold = True
cells("B3").SetStyle(style)

'Input some values that denote the input range
'for the list box.
cells("A2").PutValue("Sales")
cells("A3").PutValue("Finance")
cells("A4").PutValue("MIS")
cells("A5").PutValue("R&D")
cells("A6").PutValue("Marketing")
cells("A7").PutValue("HRA")

'Add a new list box.
Dim listBox As Aspose.Cells.ListBox = sheet.Shapes.AddListBox(2, 0, 3, 0, 122, 100)

'Set the placement type.
listBox.Placement = PlacementType.FreeFloating

'Set the linked cell.
listBox.LinkedCell = "A1"

'Set the input range.
listBox.InputRange = "A2:A7"

'Set the selection tyle.
listBox.SelectionType = SelectionType.Single

'Set the list box with 3-D shading.
listBox.Shadow = True

'Saves the file.
workbook.Save("tstlistbox.xls")

Properties

ItemCount

Gets the number of items in the list box.

public int ItemCount { get; }

Property Value

int

PageChange

Specifies the amount by which the control’s value is changed when the user clicks on the scrollbar’s page up or page down region.

public int PageChange { get; set; }

Property Value

int

SelectedCells

Gets the selected cells. Returns null if the input range is not set or no item is selected

public Cell[] SelectedCells { get; }

Property Value

Cell[]

SelectedIndex

Gets or sets the index number of the currently selected item in a list box or combo box. Zero-based.

public int SelectedIndex { get; set; }

Property Value

int

Remarks

-1 presents no item is selected.

SelectionType

Gets or sets the selection mode of the specified list box.

public SelectionType SelectionType { get; set; }

Property Value

SelectionType

Shadow

Indicates whether the combobox has 3-D shading.

public bool Shadow { get; set; }

Property Value

bool

Methods

IsSelected(int)

Indicates whether the item is selected.

public bool IsSelected(int itemIndex)

Parameters

itemIndex int

The item index.

Returns

bool

whether the item is selected.

SelectedItem(int, bool)

Sets whether the item is selected

public void SelectedItem(int itemIndex, bool isSelected)

Parameters

itemIndex int

The item index

isSelected bool

Whether the item is selected. True means that this item should be selected. False means that this item should be unselected.