Is it not possible to populate a ComboBox from another class other than the Form1.cs class?
Call ComboBox from another class
Started by LiLMsNinja, Dec 05 2009 08:08 PM
3 replies to this topic
#1
Posted 05 December 2009 - 08:08 PM
CodeMonkey +15 | CommunicationSkills -34 | ClarityUsingEnglish -55 | Clarity while pointing at the monitor and making vigorous facial expressions, occasional grunts, and mouth clicks +150
|
|
|
#2
Posted 05 December 2009 - 11:06 PM
Of course it is possible... You just need to have a reference to your combo box.
#3
Posted 06 December 2009 - 07:32 AM
I kind of thought by doing:
Then marking the combobox as public, i could use:
But NOOOO. It's gathering everything just fine but when it reports back to Form1 all my hard work dispears into no mans land.
Form1 f = new Form1
Then marking the combobox as public, i could use:
f.combobox.datasource = ablahblahblah
But NOOOO. It's gathering everything just fine but when it reports back to Form1 all my hard work dispears into no mans land.
CodeMonkey +15 | CommunicationSkills -34 | ClarityUsingEnglish -55 | Clarity while pointing at the monitor and making vigorous facial expressions, occasional grunts, and mouth clicks +150
#4
Posted 07 December 2009 - 08:09 AM
The way you are describing should work as long as you dont close your Form1 instance when you open the new class. If that is the case then you need to save the instance of Form1 as a variable and modify the variable's properties instead of the class properties.
example:
example:
public static Form1 formHolder = null; Form1 f = new Form1; formHolder = f;then use formHolder variable like so:
Form1.formHolder.combobox.datascource = ablahblahblah; Form1.formHolder.Show();


Sign In
Create Account


Back to top









