V
V
Vladimir Yurchenkov2021-11-23 13:16:19
C++ / C#
Vladimir Yurchenkov, 2021-11-23 13:16:19

How to painlessly redo the method of changing forms?

Hai!

I have already found a ton of options, but I wanted to ask how I can redo it in my case. I have a main form with a panel where I fill in the child forms. Via method:

private void OpenChildForm(Form childForm) 
{
currentChildForm = clildForm;
clildForm.TopLevel = false;
clildForm.FormBorderStyle = FormBorderStyle.None;
clildForm.Dock = DockStyle.Fill;
panelDesktop.Controls.Add(clildForm);
panelDesktop.Tag = clildForm;
clildForm.BringToFront();
clildForm.Show()
}


And accordingly, when I need to display any child form, I call: In this version, it is initialized each time as a new one. How can you write a condition so that when you switch between forms, the data inside is saved? The transition between forms can be in a different order, while there are 4 forms.

OpenChildForm(new Form2());

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Yurchenkov, 2022-01-28
@EPIDEMIASH

I saved everything in ini for the necessary forms ... when I open it, I stupidly load it.

K
koss4ok, 2021-11-26
@koss4ok

As I understand it, you want to use the same data in different forms without passing it.
You can use your project's Properties and access them from any form without passing anything.
In order to add them RMB to the project in Solution Explorer => Properties => Resources.
Thus, you will have stored resources that you can access from any part of the program and from any form.
From the code they are accessed by
ProjectName.Properties.PropertyName

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question