MFC controls use tips: Combo Box

Source: Internet
Author: User

1 The difference between addstring and insertstring

Insertstring can specify an ordinal of the displayed arrangement,

All strings are sorted by ordinal, addstring just

The string is added to the drop-down list, as the position of the string

It is not known, and when you add a string, it affects the previous

The serial number.


insertstring use case: You need to specify a sequence number by default

String display, paired with SetCurSel, to display the string


2) whether to allow editing

The Type property is set to drop List does not allow editing

The Type property is set to dropdown allow editing


3) Display drop-down content

Showdropdown


4) Getlbtext and GetWindowText differences

The Getlbtext () function. The function is a combo box member function whose prototype is:

void Getlbtext (int nIndex, CString &rstring).

Parameter description: nindex is the index value of the data in the list box, rString is a string,

Function Description: Place the data with index number nindex in the rstring variable.


GetWindowText () This function obtains the text content that is displayed. Each control has a. Content that cannot be displayed is not available


Example:

ccombobox* combo= (ccombobox*) GetDlgItem (ID_COMBO1);

int nIndex = Combo->getcursel ();

Gets the currently selected project ID.

CString stritem;

Combo->getlbtext (NIndex, stritem); is to get the selected string.


MFC controls use tips: Combo Box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.