Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBoxItems.Add Method

Adds a new item.

Syntax

VB.NETItemIndex = object.Add(ByVal Text As String) As Integer
VBItemIndex = object.Add(ByVal Text As String) As Long
C#.NETint ItemIndex = object.Add(string Text);
VC++long ItemIndex = object->Add(_bstr_t Text);
CHRESULT object->raw_Add(BSTR Text, long* ItemIndex);

object

A SftBoxItems object.

Text

The text to be added as cell text of the first (or only) column of the item.

ItemIndex

Returns the zero-based index of the item added.

Comments

The Add method adds a new item.

New items added using the Add method are always added at the end of the list. By default, new items are added at level 0. Use the Item.Level property to change an item's level.

If many items have to be added, the BulkUpdate property can be used to indicate a mass-update, which is significantly faster.

Once an item has been added, the Cell.Text property can be used to change the text for any of the available cells.

Items can be inserted at a specific location using the Items.Insert method. Items can be deleted using the Items.Remove or Items.Clear methods.

When a control is populated using Items.Add or Items.Insert, the Items.RecalcHorizontalExtent method can be used to have the control calculate the optimal horizontal scrolling area so scroll bars are enabled, depending on the Scrollbars property.

The drop down portion is automatically hidden when the combo box contents are changed using this method. The DropDown.SuppressOn method can be used to suppress hiding the drop down portion when adding/inserting items.

Examples

VB.NET

    C.Image.Width = 12
    C.Image.Height = 12
    C.ImageHAlign = Align
    PropagateImage(ItemIndex, C.Image)
End Sub

Private Sub AddColor(ByVal Text As String, ByVal Clr As Color)
    Dim i As Integer
    i = AxSftBox1.Items.Add(Text)
    AxSftBox1.get_Item(i).Level = 2
    UpdateColor(i, Clr, SftBoxHAlignConstants.halignSftBoxRight)
End Sub

Private Sub UpdateBuiltinImage(ByVal ItemIndex As Integer, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer, ByVal Align As SftBoxHAlignConstants)
    Dim C As SftBoxCell
    C = AxSftBox1.get_Cell(ItemIndex, 0)

VB6

    C.Image.Width = 12
    C.Image.Height = 12
    C.ImageHAlign = Align
    PropagateImage ItemIndex, C.Image
End Sub

Private Sub AddColor(ByVal Text As String, ByVal Clr As OLE_COLOR)
    Dim I As Integer
    I = SftBox1.Items.Add(Text)
    SftBox1.Item(I).Level = 2
    UpdateColor I, Clr, halignSftBoxRight
End Sub

Private Sub UpdateBuiltinImage(ByVal ItemIndex As Integer, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer, ByVal Align As SftBoxHAlignConstants)
    Dim C As SftBoxCell
    Set C = SftBox1.Cell(ItemIndex, 0)

C#

    C.Image.Height = 12;
    C.ImageHAlign = Align;
    PropagateImage(ItemIndex, C.Image);
}

private void AddColor(string Text, Color Clr)
{
    int i;
    i = axSftBox1.Items.Add(Text);
    axSftBox1.get_Item(i).Level = 2;
    UpdateColor(i, Clr, SftBoxHAlignConstants.halignSftBoxRight);
}

private void UpdateBuiltinImage(int ItemIndex, SftPictureImageConstants Style, int wPix, int hPix, SftBoxHAlignConstants Align)
{
    SftBoxCell C = axSftBox1.get_Cell(ItemIndex, 0);

C++

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon

    m_vBox = m_Box.GetControlUnknown();
    ASSERT(m_vBox != NULL);

    long ItemIndex = m_vBox->Items->Add("Supported Picture Types");

    m_vBox->Cell[ItemIndex][1]->Text = _T("SftBox/OCX supports numerous image types, such as GDI+ images, bitmaps, icons, ImageLists and also offers numerous built-in images.");

    // add GDI+ samples

    ItemIndex = m_vBox->Items->Add(_T("GDI+ Images"));
    m_vBox->Item[ItemIndex]->Level = 1;

See Also SftBoxItems Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.