Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBoxItems.Find Method

Searches items using text.

Syntax

VB.NETFoundIndex = object.Find(ByVal Text As String, ByVal StartIndex As Integer, ByVal ColNum As Short, ByVal Wrap As Boolean, ByVal IgnoreCase As Boolean, ByVal Exact As Boolean) As Integer
VBFoundIndex = object.Find(ByVal Text As String, ByVal StartIndex As Long, ByVal ColNum As Integer, ByVal Wrap As Boolean, ByVal IgnoreCase As Boolean, ByVal Exact As Boolean) As Long
C#.NETint FoundIndex = object.Find(string Text, int StartIndex, short ColNum, bool Wrap, bool IgnoreCase, bool Exact);
VC++long FoundIndex = object->Find(_bstr_t Text, long StartIndex, short ColNum, VARIANT_BOOL Wrap, VARIANT_BOOL IgnoreCase, VARIANT_BOOL Exact);
CHRESULT object->raw_Find(BSTR Text, long StartIndex, short ColNum, VARIANT_BOOL Wrap, VARIANT_BOOL IgnoreCase, VARIANT_BOOL Exact, long* FoundIndex);

object

A SftBoxItems object.

Text

The text to be searched.

StartIndex

The zero-based index of the item where the search is to begin (including the item at StartIndex).

ColNum

The zero-based index of the column to be searched. Only cells in this column will be searched and only one column can be searched at a time.

Wrap

Specify True to allow the search to wrap around and begin at the first item when the end of the list is reached. If False is specified, the search will end at the end of the list.

IgnoreCase

Specify True to compare Text and the cell text of each item ignoring differences between uppercase and lowercase characters. Specify False for a case sensitive comparison.

Exact

If True is specified, Text must match the cell text completely (still depending on IgnoreCase). If False is specified, the Find method will return the first item whose cell text starts with Text.

FoundIndex

Returns the zero-based index of the item found. -1 is returned if no match was found.

Comments

The Find method searches items using text.

The string described by Text is compared to the Cell.Text property of all items involved in the search. The search starts at the item described by StartIndex and is restricted to the column specified by ColNum. If an item with a matching Cell.Text property is found, its zero-based index is returned, otherwise -1 is returned.

Only one column can be searched at a time. The comparison of Text and the Cell.Text property may be case sensitive based on the IgnoreCase argument.

If the Cell.Text starts with the string in Text, it is considered a match if Exact is False. If Exact is True, the Cell.Text property must be completely equal to Text.

Examples

VB.NET

    fontNames.Items.RecalcHorizontalExtent(0)
End Sub

Private Sub UpdateFontStyles()
    ' add all styles for the current font name
    If fontNames.Items.Selection >= 0 Then
        Dim OldText As String = fontStyles.Edit.Text
        fontStyles.Items.AddFontStyles(fontNames.get_Cell(fontNames.Items.Selection, 0).Text, 0, "", "")
        Dim index As Integer = fontStyles.Items.Find(OldText, 0, 0, False, True, True)
        If index < 0 Then index = 0
        fontStyles.Items.Selection = index
    Else
        fontStyles.Items.Clear()
    End If
    PerformSort(fontStyles, SftBoxSortConstants.sortSftBoxAscending)
    fontStyles.Columns.MakeOptimal(0)

VB6

End Sub

Private Sub UpdateStyles()
    Dim OldText As String, Index As Long
    ' add all styles for the current font name
    If FontNames.Items.Selection >= 0 Then
        OldText = FontStyles.Edit.Text
        FontStyles.Items.AddFontStyles FontNames.Cell(FontNames.Items.Selection, 0).Text, 0, "", ""
        Index = FontStyles.Items.Find(OldText, 0, 0, False, True, True)
        If Index < 0 Then Index = 0
        FontStyles.Items.Selection = Index
    Else
        FontStyles.Items.Clear
    End If
    PerformSort FontStyles
    FontStyles.Columns.MakeOptimal 0

C#

}

private void UpdateFontStyles()
{
    // add all styles for the current font name
    if (fontNames.Items.Selection >= 0) {
        string OldText = fontStyles.Edit.Text;
        fontStyles.Items.AddFontStyles(fontNames.get_Cell(fontNames.Items.Selection,0).Text, 0, "", "");
        int index = fontStyles.Items.Find(OldText, 0, 0, false, true, true);
        if (index < 0) index = 0;
        fontStyles.Items.Selection = index;
    } else
        fontStyles.Items.Clear();
    PerformSort(fontStyles, SftBoxSortConstants.sortSftBoxAscending);
    fontStyles.Columns.MakeOptimal(0);
    fontStyles.Items.RecalcHorizontalExtent(0);

C++

    // add all styles for the current font name
    ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown();
    ISftBoxPtr vFontStyles = m_FontStyles.GetControlUnknown();

    if (vFontNames->Items->Selection >= 0) {
        CString OldText((LPCTSTR) vFontStyles->Edit->Text);
        vFontStyles->Items->AddFontStyles(vFontNames->Cell[vFontNames->Items->Selection][0]->Text, 0, "", "");
        long index;
        vFontStyles->Items->raw_Find((_bstr_t)OldText, 0, 0, VARIANT_FALSE, VARIANT_TRUE, VARIANT_TRUE, &index);
        if (index < 0) index = 0;
        vFontStyles->Items->Selection = index;
    } else
        vFontStyles->Items->Clear();
    PerformSort(vFontStyles, sortSftBoxAscending);
    vFontStyles->Columns->MakeOptimal(0);
    vFontStyles->Items->RecalcHorizontalExtent(0);

See Also SftBoxItems Object | Object Hierarchy


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