c# - Calling user created method in Form1 in Main() -


i have method in form1.cs called generatecomboboxlist() , want call in main method contents of combo box generated when application started.

public void generatecomboboxlist() {      cmbserverdatabase.items.add("1");      cmbserverdatabase.items.add("2");      cmbserverdatabase.items.add("3"); } 

however, when begin type generatecomboboxlist() in main method, intellisense not pick up. can going wrong?

you need instance of form1 in main method, can call method, but, don't that. instead call method in form_load event or overload onload (see: this).

your main method in program.cs should responsible specifying/loading start form. later in form's load event can do:

private void form1_load(object sender, eventargs e) {    generatecomboboxlist() } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -