hangman
March 1st, 2006, 07:36 AM
Hi everyone.
I'm having a problem with selecting text in a combobox. I have comboboxes filled with items that are stoded like this:
code|description
When a user selects a code/description pair, I want the combobox to only show the code and not the description. The dropdownstyle needs to be dropdown by the way, cause I've already solved this problem a couple of times with a dropdownlist, but in this box, the user needs to be able to input things himself...
So far, this is what I have:
Private Sub cmbICD9Diag_DropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.DropDownClosed
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
txtDiagnoseOmsch.Focus()
cmbICD9Diag.Focus()
End Sub
Private Sub cmbICD9Diag_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.LostFocus
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
End Sub
Private Sub cmbICD9Diag_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.SelectedIndexChanged
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
End Sub
The only time it happens the right way, is when you manually click somewhere outside the combobox. Even the forced loss of focus (putting the focus on a textbox and then on the combobox again) does cause a cmbICD9Diag_LostFocus event, but the text still displays the full code|description pair...
If anyone would be able to tell me what I'm doing wrong or whether there's an easy way to work around this, please let me know, I'd really appreciate any help!
Thanks a lot in advance!
I'm having a problem with selecting text in a combobox. I have comboboxes filled with items that are stoded like this:
code|description
When a user selects a code/description pair, I want the combobox to only show the code and not the description. The dropdownstyle needs to be dropdown by the way, cause I've already solved this problem a couple of times with a dropdownlist, but in this box, the user needs to be able to input things himself...
So far, this is what I have:
Private Sub cmbICD9Diag_DropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.DropDownClosed
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
txtDiagnoseOmsch.Focus()
cmbICD9Diag.Focus()
End Sub
Private Sub cmbICD9Diag_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.LostFocus
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
End Sub
Private Sub cmbICD9Diag_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbICD9Diag.SelectedIndexChanged
cmbICD9Diag.Text = cmbICD9Diag.SelectedItem.ToString.Substring(0, cmbICD9Diag.SelectedItem.ToString.LastIndexOf("|"))
End Sub
The only time it happens the right way, is when you manually click somewhere outside the combobox. Even the forced loss of focus (putting the focus on a textbox and then on the combobox again) does cause a cmbICD9Diag_LostFocus event, but the text still displays the full code|description pair...
If anyone would be able to tell me what I'm doing wrong or whether there's an easy way to work around this, please let me know, I'd really appreciate any help!
Thanks a lot in advance!