c# - Adding Methods To Windows Form? -
i have 2 windows forms, parent , child. parent main form. child dialog user can edit details.
when button clicked on parent form, loads child form. so:
private void add_account_click(object sender, eventargs e) { this.account_add_edit = new form2(); account_add_edit.test(); account_add_edit.showdialog(); }
as can see i've created new form, tried call function new form, , showed form. problem method form not being called. getting error on ide says windows.forms.form not contain method test.
i've created method in child form:
public static string test(string val) { this.username = val; }
any ideas i'm doing wrong?
your method defined static , not posiible call on instace. should eaither not make static, or call static:
form2.test();
Comments
Post a Comment