设置值后组合框不显示文本 [英] Comboboxes not presenting text after setting value

查看:91
本文介绍了设置值后组合框不显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很奇怪,我找不到答案.我有一个带有多个控件的表单,其中有三个组合框.还有一个数据网格,其中在数据网格中选择一行可在下面的表单控件中提供可编辑的详细信息.有趣的是,其中一个组合框已填充,而另两个则没有.我已通过编程方式对其进行了检查,并且所设置的值所选择的项目是正确的,并且包含所有正确的信息,但是该框的文本区域为空白.

手动更改组合框上的选择,然后再次在网格上重新启动整个选择,这样便可以正常工作!

顺便说一句,通过设置值我的意思是沿着

This is weird and I cannot find an answer to this. I have a form with several controls on it, of which there are three Comboboxes. There is also a datagrid where selecting a row in the datagrid provides editable details in the form controls below. The funny thing is that one of the comboboxes gets populated whilst the other two don''t. I''ve checked it programatically and the item being selected by the set value is correct and contains all the right information but the text area of the box is blank.

Change the selection on the combobox manually, then restart the whole selection on the grid again and presto things work!

BTW, by setting value I mean along the lines of

MyCombo.SelectedValue = ((MyItem)MyDatagridView.DataboundItem).MyComboValue;


(当然,它比上面的代码段更复杂和完整:))

组合框是数据绑定的,并且数据正确.

我可能要添加的另一件事是,当应该将SelectedIndex保留为其他值时,SelectedIndex仍为0. (基本上总结了我的整个困境)

有什么想法吗?


(Of course, its a bit more complicated and complete than the snippet above :) )

The comboboxes are databound and the data is correct.

Another thing I might add is that the SelectedIndex remains 0 when it should be something else. (That basically summarizes my whole predicament)

Any ideas?

推荐答案

也许尝试同时设置SelectedValue和SelectedText?或者,也许可以更好地设置SelectedIndex.
Perhaps try setting both SelectedValue and SelectedText? Or maybe you''d have better luck setting SelectedIndex.


这篇关于设置值后组合框不显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆