I 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. Other), 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?
m_Cmb_State.GetLBText(m_Cmb_State.GetCurSel(), csState);
if (0 == csState.CompareNoCase(_T("OTHER")))
{
m_pComboEdit->ReplaceSel(_T("Type here..."));
}