Dela via


CMFCRibbonComboBox Class

The CMFCRibbonComboBox class implements a combo box control that you can add to a ribbon bar, a ribbon panel, or a ribbon popup menu.

class CMFCRibbonComboBox : public CMFCRibbonEdit

Members

Constructors

Name

Description

CMFCRibbonComboBox::CMFCRibbonComboBox

Constructs a CMFCRibbonComboBox object.

Public Methods

Name

Description

CMFCRibbonComboBox::AddItem

Appends a unique item to the list box.

CMFCRibbonComboBox::DeleteItem

Deletes a specified item from the list box.

CMFCRibbonComboBox::EnableDropDownListResize

Specifies whether the list box can change size when it drops down.

CMFCRibbonComboBox::FindItem

Returns the index of the first item in the list box that matches a specified string.

CMFCRibbonComboBox::GetCount

Returns the number of items in the list box.

CMFCRibbonComboBox::GetCurSel

Gets the index of the currently selected item in the list box.

CMFCRibbonComboBox::GetDropDownHeight

Gets the height of the list box when the list box is dropped down.

CMFCRibbonComboBox::GetIntermediateSize

Returns the size of the combo box as displayed in intermediate mode.

CMFCRibbonComboBox::GetItem

Returns the string associated with an item at a specified index in the list box.

CMFCRibbonComboBox::GetItemData

Returns the data associated with an item at a specified index in the list box.

CMFCRibbonComboBox::HasEditBox

Indicates whether the control contains an edit box.

CMFCRibbonComboBox::IsResizeDropDownList

Indicates whether or not the list box can be resized.

CMFCRibbonComboBox::OnSelectItem

Called by the framework when the user selects an item in the list box.

CMFCRibbonComboBox::RemoveAllItems

Deletes all items from the list box and clears the edit box.

CMFCRibbonComboBox::SelectItem

Selects an item in the list box.

CMFCRibbonComboBox::SetDropDownHeight

Sets the height of the list box when it is dropped down.

Remarks

The ribbon combo box consists of a list box combined with either a static label or label that can be edited by the user. You must specify which type you want when you create your ribbon combo box.

Example

The following example demonstrates how to construct an object of the CMFCRibbonComboBox class, add an item to the combo box, select an item in the combo box, and add a combo box to a panel.

// Create a simple combo box with two entries: 
    // The first parameter is the id of the combo box. 
    // The third parameter is the width of the combo box in pixels. 
    // The fourth parameter is the display label of the combo box. 
    // The fifth parameter is the index of the small image of the combo box.
    CMFCRibbonComboBox *pComboSimple = new CMFCRibbonComboBox(-1, FALSE, -1, 0, -1);

    // Add two items to the combo box and select the first item in the list:
    pComboSimple->AddItem(_T("Hi!"));
    pComboSimple->AddItem(_T("Hello!"));
    pComboSimple->SelectItem(0);

    // Add combo button to "Favorites" panel:
    // CMFCRibbonPanel* pPanelFavorites
    pPanelFavorites->Add(pComboSimple);

Inheritance Hierarchy

CObject

   CMFCRibbonBaseElement

      CMFCRibbonButton

         CMFCRibbonEdit

            CMFCRibbonComboBox

Requirements

Header: afxribboncombobox.h

See Also

Concepts

MFC Hierarchy Chart

Reference

CMFCRibbonEdit Class

Other Resources

Classes (MFC Feature Pack)