private void m_listBox_SelectedIndexChanged(object sender, EventArgs e)
{
// If the selection came from choosing in the list box, we need to hide the list
// box and focus on the text box.
bool fNeedFocus = false;
if (ListBox.Form != null && ListBox.Form.Visible && !ListBox.KeepDropDownListDuringSelection)
{
HideDropDownBox();
fNeedFocus = true;
}
if (ListBox.SelectedIndex == -1)
{
if (DropDownStyle != ComboBoxStyle.DropDown)
{
// Clear out the text box, since there isn't a selection now.
// (Don't do this if typing is allowed, because we get a selection change to -1
// when the user types something not in the list, and we don't want to erase what
// the user typed.)
PreviousTextBoxText = m_comboTextBox.Tss; // save for future use (if needed)
ITsStrBldr bldr = m_comboTextBox.Tss.GetBldr();
ITsTextProps props = bldr.get_Properties(0);
string str = bldr.GetString().Text;
int cStr = str != null ? str.Length : 0;
bldr.Replace(0, cStr, String.Empty, props);
// Can't do this since string might be null.
// bldr.Replace(0, bldr.GetString().Text.Length, String.Empty, props);
m_comboTextBox.Tss = bldr.GetString();
}
}
else
{
// It's a real selection, so copy to the text box.
PreviousTextBoxText = m_comboTextBox.Tss; // save for future use (if needed)
m_comboTextBox.Tss = ListBox.SelectedTss;
}
if (fNeedFocus)
m_comboTextBox.Focus();
// Finally notify our own delegates.
RaiseSelectedIndexChanged();
}
private void m_listBox_SameItemSelected(object sender, EventArgs e)