【发布时间】:2012-10-10 09:17:39
【问题描述】:
我有这个代码
private void FrmNovedadMedidas_SelectionChangeCommitted(object sender, EventArgs e)
{
ComboBox c = (ComboBox)sender;
CargarMedidasPorIdTipoMedida(Convert.ToInt16(c.SelectedValue));
this.txtBoxNombreTipoMedida.Text = c.SelectedText;
}
在c.SelectedValue 中获得了选择的新值(用户在组合中选择的值)。
但是在c.SelectedText 中,我得到了 ComboBox 的旧值(我的意思是,在用户更改选择之前的那个值)。
是否有任何属性可以给我新的选定文本? 我想避免每次都在绑定到 ComboBox 的 DataSet 中进行搜索。
我已阅读 this 但不起作用,我在 ComboBox 中没有 CommitEdit()
编辑:
c.Text 也给了我旧的
【问题讨论】:
-
我似乎记得这种情况与 ComboBox 的 DropDownStyle 有关。您能否尝试不同的样式,看看 Text 属性是否设置为 SelectionChangeCommited 中的新值?
-
使用 DropDownList 解决了这个问题,也解决了我正在检查的另一个问题。非常感谢 !!请将其发布为答案,以便我接受它
标签: c# .net winforms combobox selectedindexchanged