如何在 vb.net 中刷新组合框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15232527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to refresh combobox in vb.net
提问by Rodmar Pusung
this is my sample codes..see the problems on how to refresh items in a combo box.
这是我的示例代码......查看有关如何刷新组合框中项目的问题。
Private Sub cbo_payMO_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_payMO.SelectedIndexChanged<br>
Select Case (cbo_payMO.Text)
Case "JANUARY"
cbo_payMO1.refresh() -- in case JANUARY I WANT TO REFRESH CBO_PAYMO1
to readd an items
Case "FEBRUARY"
cbo_payMO1.Items.Remove("JANUARY")
End Select
End Sub
回答by David T. Macknet
The .refresh()call you have there isn't what you're looking for - you're wanting to clear out the ListItems and then add a new set, with different items. I'd suggest maintaining a list or collection or array of some sort, separate from the .Itemsof that combo box. Then you need to call .Items.Clear()followed by .Items.AddRange(SomeListOfStuff)
.refresh()你在那里的电话不是你要找的 - 你想清除 ListItems 然后添加一个新的集合,有不同的项目。我建议维护一个列表或集合或某种类型的数组,与.Items该组合框的分开。然后,你需要调用.Items.Clear()之后.Items.AddRange(SomeListOfStuff)

