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? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -