Wywołanie drugiego forma

0

Szanowni Państwo :),

Mam problem, może i trywialny, jednak nie wiem jak go rozwiązać, a mianowicie po kliknięciu menu chce wywołać drugie okno jednak nie wiem jak to uczynić
Form2:


namespace Linia
{
    public partial class Form2 : Form
    {
        private Form1 Form1;
        public Form2(Form1 Form)
        {
            InitializeComponent();
            this.Form1 = Form;
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog MyDialog = new ColorDialog();
            // Keeps the user from selecting a custom color.
            MyDialog.AllowFullOpen = false;
            // Allows the user to get help. (The default is false.)
            MyDialog.ShowHelp = true;
            // Sets the initial color select to the current text color.
            MyDialog.Color = Form1.circularProgressBar1.ProgressColor;

            // Update the text box color if the user clicks OK 
            if (MyDialog.ShowDialog() == DialogResult.OK)
                Form1.circularProgressBar1.ProgressColor = MyDialog.Color;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ColorDialog MyDialog = new ColorDialog();
            // Keeps the user from selecting a custom color.
            MyDialog.AllowFullOpen = false;
            // Allows the user to get help. (The default is false.)
            MyDialog.ShowHelp = true;
            // Sets the initial color select to the current text color.
            MyDialog.Color = Form1.circularProgressBar2.ProgressColor;

            // Update the text box color if the user clicks OK 
            if (MyDialog.ShowDialog() == DialogResult.OK)
                Form1.circularProgressBar2.ProgressColor = MyDialog.Color;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ColorDialog MyDialog = new ColorDialog();
            // Keeps the user from selecting a custom color.
            MyDialog.AllowFullOpen = false;
            // Allows the user to get help. (The default is false.)
            MyDialog.ShowHelp = true;
            // Sets the initial color select to the current text color.
            MyDialog.Color = Form1.circularProgressBar3.ProgressColor;

            // Update the text box color if the user clicks OK 
            if (MyDialog.ShowDialog() == DialogResult.OK)
                Form1.circularProgressBar3.ProgressColor = MyDialog.Color;
        }
    }
}

I fragment Form1:

 private void ustawieniaWizualneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2.ActiveForm.ShowDialog();

        }

Niestety powyższe rozwiązanie nie funkcjonuje

0

A utwórz obiekt Form2 normalnie przez jego konstruktor i wywołaj to ShowDialog() na nim

0

@kzkzg:

public class Form2
       {
           
       }

tak?

1

Przecież Ci już wszystko powiedzieli :|

Form2 f = new Form2(); // <-- utworzenie formy
f.ShowDialog(); <-- pokazanie modalnie
f.Dispose(); <-- zniszczenie formy

1 użytkowników online, w tym zalogowanych: 0, gości: 1