问题描述
我想以编程方式将组合框设置回第一项.由于组合框中的数据是动态的,因此我不能仅将文本设置为一个值.
我已经尝试过mycombobox.SelectedIndex = 0; -代码已执行,但仍显示先前选择的项目.
任何帮助将不胜感激.
谢谢
[更新]
我正在用 WinForms 编写,此事件附加在SelectedIndexChanged
处,用于另一个组合框.我认为它应该工作,而且我做得正确,只是不确定为什么不行.也许我需要打电话给Application.DoEvents()
; ?
[/UPDATE]
Hi,
I would like to programactically set a combobox back to the first item. Since the data in the combobox is dynamic, I can''t just simply set the text to a value.
I''ve tried mycombobox.SelectedIndex = 0; - The code executes but it still displaying the previously selected item.
Any help would be greatly appreciated.
Thank you,
[UPDATE]
Hi,
I''m writing in WinForms and this event is attached at a SelectedIndexChanged
for a different combination box. I thought it should work and I was doing it correctly, I''m just not sure why it''s not. Maybe I need a call to Application.DoEvents()
; ?
[/UPDATE]
推荐答案
这篇关于将组合框设置为第一项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!