Reputation: 12682
I have this code
private void FrmNovedadMedidas_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox c = (ComboBox)sender;
CargarMedidasPorIdTipoMedida(Convert.ToInt16(c.SelectedValue));
this.txtBoxNombreTipoMedida.Text = c.SelectedText;
}
in c.SelectedValue
got the new value of the selection (the one that the user has selected in the Combo).
But in c.SelectedText
I got the old value of the ComboBox (I mean, the one that was before the user change the selection).
Is there any property that can give me the new Selected Text? I want to avoid to search in the DataSet binded to the ComboBox everytime.
I've read this but doesn't work, I don't have CommitEdit()
in ComboBox
edit:
c.Text
also gives me the old one
Upvotes: 4
Views: 6937
Reputation: 1
c.SelectedValue()
returns null
for me.
c.GetItemText(c.SelectedItem)
works for me though. Changing the dropdownstyle wasn't an option.
Upvotes: 0
Reputation: 129
Try the SelectedIndexChanged
event on the ComboBox versus the SelectionChangeCommited
event. Then use c.Text
to get the value the user just selected.
Upvotes: 1
Reputation: 5380
I seem to remember this situation having to do with the DropDownStyle
of the ComboBox.
Can you please try different styles and see if the Text property is set to the new value inside SelectionChangeCommited
?
As per your comment, it seems using DropDownList
style solves the issue.
Cheers
Upvotes: 4
Reputation: 12682
I found something.
c.GetItemText(c.SelectedItem)
Is there a directly properties, post it please. Thanks for readme anyway.
Upvotes: 2