Hello. There is a main window in which the user works, and if necessary to change any data, he presses the edit button and a new window is created. In it, I transmit information from the main without any problems. In the new window, the user edits the data and there are 2 buttons on it, one closes the window, and the second one - “Save”. that the child form "refuses" to work with the main one. How to fix it?
Thank you, @Konstantin25 . Here's something that came up, but it seems that is too abstruse ...
---- ``-Создаю статический класс public static class Values { public static string V1; public static string V2; //........ }
On the button to display the second form in the main form I write
private void button2_Click(object sender, RoutedEventArgs e) { Form_add = new Form_Add(); //Здесь передаю значения из главной в дочернюю и пишу это... Form_add.Dobavit+=Dobavlenie; Form_add.ShowDialog(); } void Dobavlenie(object sender,EventArgs e) { label1.Content = Values.V1;//В этой метке,например на главной форме я //получу значения из статического класса, // а в него внесу значения из дочерней формы }
In the child window, when I press the button, I write
private void button_dobavit_(object sender, RoutedEventArgs e) { Values.V1= this.DatePicker1.SelectedValue.ToString(); Dobavit(sender, e); this.Close(); } public event EventHandler Dobavit = delegate { };