Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am using Combo-box of type CComboBox. In it I am filling state values and one special value "Other"(if some user wants to enter a different state) at dialog initialization. When I select Other, I want Combo-box to display text as "Type here" instead of selected value(i.e. Ohter), but it is not displaying.

For example: Suppose I filled states as State1, State2, State3 and Other in combo-box. When I select State1, then combo-box should display State1 in its edit control. But when I select "Other" then combo-box should display "Type here" instead of "Other" in its edit control.

For that I have checked on "OnCbnSelchangeCmbState" event if user selected Other. If he has, then I used SetWindowText(_T("Type here")). 2nd way I have tried is by using ReplaceSel(_T("Type here")). Combo-box is displaying "Type here" till OnCbnEditchangeCmbState event, but after that it is setting empty text. Why this is happening?

C#
m_Cmb_State.GetLBText(m_Cmb_State.GetCurSel(), csState);
if (0 == csState.CompareNoCase(_T("OTHER")))
{
    m_pComboEdit->ReplaceSel(_T("Type here..."));
}
Posted
Updated 22-Jul-15 1:51am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900