//перегрузка конструктора формы, в которую передается ссылка на форму-родителя(чет не рабит) //public Sign_in_form(Main_form _mainform) //{ // InitializeComponent(); // mainform = _mainform; //} private void button1_Click(object sender, EventArgs e) { MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show("Do you confirm your choice?", "confirm", buttons); if (result == DialogResult.Yes) { using (AccountContext db = new AccountContext()) { var accounts = db.Accounts; foreach (Account u in accounts) { if(u.email == textBox1.Text & u.password == textBox2.Text) { Main_form.UserName = u.name; //обращение к главной форме через объект mainform = this.Owner as Main_form; //можно и так) mainform.toolStripStatusLabel4.Text = u.name; //toolStripStatusLabel4.Text = u.name; //нельзя ибо нестатическое поле //А еще очень даже неплохо воспользоваться событиями. MessageBox.Show("Вход выполнен успешно"); //нет ли двух попаданий? } } //смешной костыль if(Main_form.UserName == "No User Registered") { MessageBox.Show("Неверный логин или пароль"); } } } this.Close(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); form = new Main_form(); Application.Run(form); }
// List<int> _tselected_nd_list = new List<int>(); //public List<int> selected_nd_list //{ // get { return _tselected_nd_list; } //} public view_settings_form(Main_form t_form, ref pslg_datastructure t_fe_object) { InitializeComponent(); my_parent_form = t_form; fe_object = t_fe_object; }
public Nodal_prop_form(Main_form t_form, ref pslg_datastructure t_fe_object) { InitializeComponent(); my_parent_form = t_form; fe_object = t_fe_object; }