Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:34:42+00:00 2026-06-10T05:34:42+00:00

Form1 frm = new Form1(); frm.mdiParent=this; frm.show(); I want to create a global method

  • 0
Form1 frm = new Form1();
frm.mdiParent=this;
frm.show();

I want to create a global method showFrm(Form formToShow) which i can access from anywhere in my project.

I’ve tried.

public void showFrm(Form formToShow)
{
    formToShow f=new formToShow();//getting error here
    f.mdiParent= mdiForm;
    f.show();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:34:43+00:00Added an answer on June 10, 2026 at 5:34 am

    Put this method in your “only parent form” class:

    public void ShowMdiChild<T>() where T: Form, new()
    {
        var form = new T();
        form.MdiParent = this;
        form.Show();
    }
    

    Usage:

    yourOnlyParentForm.ShowMdiChild<SomeForm>();
    

    I would also remind you that C# is case-sensitive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Form1 frm = new Form1(); frm1.ShowDialog(); I use this to create new form to
Some method call this method which has this code: Form frm = new Form();
Which is a better way to show a modal dialog? form1 frm=new form1(); frm.showDialog()
I have a form (for example, abc.frm ). I want the duplicate form (for
Consider two forms: form1 and form2 form1 calls form2 : form2 frm = new
Iam new in cakephp ,I need to validate a form. This is the code:
Hi I have the following script in my form function pdf() { var frm
public Form1() { InitializeComponent(); Collection<Test> tests = new Collection<Test>(); tests.Add(new Test(test1)); tests.Add(new Test(test2)); foreach
I have a form (Form1) that has a NotifyIcon on it. I have another
public class Form1 : System.Windows.Forms.Form { private void eachCornerPix (object sender, PaintEventArgs e, out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.