How can I call another form from within one forms control events. like initiating a form on button click?

Dani AI

Generated

A quick clarification that builds on ’s suggestion and ’s follow-up: in WinForms you can either open a form modelessly (so the main form stays active behind it) or modally (main form is blocked until the child closes). Both are correct approaches depending on whether you want interaction with the main window while the About window is open.

Modeless (reuse a single instance, keep main active behind):

private AboutForm _about;

private void aboutButton_Click(object sender, EventArgs e)
{
    if (_about == null || _about.IsDisposed)
    {
        _about = new AboutForm();
        _about.Owner = this;
        _about.FormClosed += (s, a) => _about = null;
    }

    if (!_about.Visible)
        _about.Visible = true;

    _about.BringToFront();
    _about.Activate();
}

This prevents multiple copies, restores the form if hidden, and keeps a clean reference when it closes.

Modal (block the main form until the about window closes):

using (var dlg = new AboutForm())
{
    dlg.StartPosition = FormStartPosition.CenterParent;
    dlg.ShowDialog(this); // modal: user must close dlg before returning
}

Tips and gotchas: set Owner so the child stays on top of the parent and centers correctly. If you keep a field reference, check IsDisposed before reusing it or clear the reference in FormClosed. For passing data, use constructor parameters or public properties on the child form. Never create or update forms from a non-UI thread — marshal via Invoke. If an MDI layout is required, use MdiParent instead. These patterns address the common pitfalls new C# WinForms users encounter when opening secondary windows.

Recommended Answers

All 4 Replies

do you mean to make a new copy of the form, or change to an existing one?

Change to an existing one, keeping the main one intact at background, like opening an about.form from Main form's button or about menu item

do you mean to make a new copy of the form, or change to an existing one?

Well as long as you have access to the variable your "about" form was instantiated in, you can do exactly that, you would do about.Show() etc.

Ok thanks, got it. I'm new at C# so having difficulties finding n locating simple things. Haven't got much time either...

Thanks again.

Well as long as you have access to the variable your "about" form was instantiated in, you can do exactly that, you would do about.Show() etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.