Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

Populate combobox globally(using class file), using vb.net. Anyone help me out please.

Regards
Rajesh V
Posted
Comments
Rajesh Anuhya 24-Jun-13 7:49am    
What do you mean by globally
Rajesh Anuhya 24-Jun-13 7:50am    
Do you want to load it in library?
Rajesh Vetrivel 24-Jun-13 7:56am    
Yes in library. Rajesh Anuhya...

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.
 
Share this answer
 
use the below code in the librabry and pass your combobox as reference parameter
C#
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);

Thanks
--RA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900