HyperEngineer
Programmer
I have a problem getting the string out of the edit control of a drop down combo box. I can into the edit control but can't seem to do anything else with it. Here is some code:
{
// TODO: Add your control notification handler code here
// Check that a string is entered
// Get the current selection index
CString strSelected;
CString strAdd;
int nIndex = m_cboString.GetCurSel();
if (nIndex == CB_ERR)
{
m_cboString.GetLBText(-1,strAdd);
m_cboString.AddString(strAdd);
m_cboString.SelectString(0,strAdd);
nIndex = m_cboString.GetCurSel();
}
if (nIndex != CB_ERR)
{
// Store the selection
m_cboString.GetLBText(nIndex, strSelected);
if ((strSelected != ""
)
{
AfxMessageBox("valid string"
;
}
else
{
AfxMessageBox("invalid string"
;
}
}
}
This does not work. GetLBText does not like a negative index. Would appreciate some help.
thanks,
HyperEngineer
{
// TODO: Add your control notification handler code here
// Check that a string is entered
// Get the current selection index
CString strSelected;
CString strAdd;
int nIndex = m_cboString.GetCurSel();
if (nIndex == CB_ERR)
{
m_cboString.GetLBText(-1,strAdd);
m_cboString.AddString(strAdd);
m_cboString.SelectString(0,strAdd);
nIndex = m_cboString.GetCurSel();
}
if (nIndex != CB_ERR)
{
// Store the selection
m_cboString.GetLBText(nIndex, strSelected);
if ((strSelected != ""
{
AfxMessageBox("valid string"
}
else
{
AfxMessageBox("invalid string"
}
}
}
This does not work. GetLBText does not like a negative index. Would appreciate some help.
thanks,
HyperEngineer