如何在全球范围内填充组合框 [英] how to populate combobox globally
本文介绍了如何在全球范围内填充组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用vb.net全局填充组合框(使用类文件)。任何人都帮帮我。
问候
Rajesh V
Hi,
Populate combobox globally(using class file), using vb.net. Anyone help me out please.
Regards
Rajesh V
推荐答案
除非您编写的库专门处理UI元素,否则您的库不应该像UI一样触及UI控件。它应该返回一个列表,你的UI代码填充控件。
Unless your writing a library that deals specifically and only with UI elements, your library shouldn't be touching a UI control, like a Combo. It should be returning a list that your UI code populates the control with.
在librabry中使用下面的代码并传递你的组合框作为参考参数
use the below code in the librabry and pass your combobox as reference parameter
public void LoadCombobox(ref ComboBox mycombobox)
{
//Clear the items
mycombobox.Items.Clear();
//Add the items
mycombobox.Items.Add("Rajesh");
mycombobox.Items.Add("Anuhya");
}
调用方法
Call the method
LoadCombobox(ref ComboBox1);
谢谢
--RA
Thanks
--RA
这篇关于如何在全球范围内填充组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文