Condividi tramite


CComboBox::SetMinVisibleItems

Sets the minimum number of visible items in the drop-down list of the current combo box control.

BOOL SetMinVisibleItems(
     int iMinVisible
);

Parameters

Parameter

Description

[in] iMinVisible

Specifies the minimum number of visible items.

Return Value

true if this method is successful; otherwise, false.

Requirements

Header: afxwin.h

This method is supported in Windows XP and later.

Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.

Remarks

This method sends the CB_SETMINVISIBLE message, which is described in the Windows SDK.

Example

The following code example defines the variable, m_combobox, that is used to programmatically access the combo box control. This variable is used in the next example.

    // Variable to access the combo box control
    CComboBox m_combobox;

The following code example inserts 20 items into the drop-down list of a combo box control. Then it specifies that a minimum of 10 items be displayed when a user presses the drop-down arrow.

    // Add extra initialization here.

    // Add 20 items to the combo box. The Resource Editor
    // has already been used to set the style of the combo
    // box to CBS_SORT.
    CString str;
    for (int i = 1; i <= 20; i++)
    {
        str.Format(_T("Item %2d"), i); 
        m_combobox.AddString(str);
    }
    // Set the minimum visible item
    m_combobox.SetMinVisibleItems( 10 );
    // Set the cue banner
    m_combobox.SetCueBanner(_T("Select an item..."));

    // End of extra initialization.

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::GetMinVisible

CComboBox::ShowDropDown

CB_SETMINVISIBLE

Other Resources

CComboBox Members