c# - I want a selected item in combobox on formlogin to be automatically changed in Main form -


i have 2 forms:

  • first loginform, contains combobox1 user select
  • and main form, display selected item in combobox1 on label1 in loginform.

i tried :

label1.text = "welcome, "+ (new formlogin()).combobox1.selecteditems.tostring(); 

,but i've got error message:

unhandled exception has occurred in application. 

there many ways this... simplest way can think of:

add property formmain:

public string username { get; set; } 

then, in formmain's load event:

label1.text = this.username; 

then, formlogin when show mainform:

formmain form = new formmain(); form.username = combobox1.selecteditems.tostring(); form.show(); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -