c# - I want a selected item in combobox on formlogin to be automatically changed in Main form -
i have 2 forms:
- first
loginform
, containscombobox1
user select - and main form, display selected item in
combobox1
onlabel1
inloginform
.
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
Post a Comment