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

  • Home
  • SEARCH
  • 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 132823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:19:26+00:00 2026-05-11T06:19:26+00:00

I have a custom class file in C# that I inherited and partially extended.

  • 0

I have a custom class file in C# that I inherited and partially extended. I am trying to re factor it now as I have just enough knowhow to know that with something like generics(I think) I could greatly condense this class.

As an inexperienced solo dev I would greatly appreciate any direction or constructive critism any can provide.

Don’t be gentle! I appreciate your time and have a blessed day! I am preemptively sorry for the length.

using System.Windows.Forms; using DevExpress.XtraEditors; using DevExpress.XtraTab;  namespace psWinForms {     public static class WinFormCustomHandling     {         public static void ShowXFormInControl(Form frm,              ref XtraTabPage ctl, FormBorderStyle style)         {             frm.TopLevel = false;             frm.ControlBox = false;             frm.Parent = ctl;             frm.FormBorderStyle = style;             frm.Left = 0;             frm.Top = 0;             frm.Width = ctl.Width + 4;             frm.Dock = DockStyle.Fill;             frm.Show();              //IMPORTANT: .Show() fires a form load event             frm.BringToFront();         }          public static void ShowXFormInControl(Form frm,              ref XtraPanel ctl, FormBorderStyle style)         {             frm.TopLevel = false;             frm.ControlBox = false;             frm.Parent = ctl;             frm.FormBorderStyle = style;             frm.Left = 0;             frm.Top = 0;             frm.Width = ctl.Width + 4;             frm.Dock = DockStyle.Fill;             frm.Show();             //IMPORTANT: .Show() fires a form load event             frm.BringToFront();          }          public static void ShowXFormInControl(XtraForm Xfrm,              ref XtraTabPage ctl, FormBorderStyle style)         {             Xfrm.TopLevel = false;             Xfrm.ControlBox = false;             Xfrm.Parent = ctl;             Xfrm.FormBorderStyle = style;             Xfrm.Left = 0;             Xfrm.Top = 0;             Xfrm.Width = ctl.Width + 4;             Xfrm.Dock = DockStyle.Fill;             Xfrm.Show();             //IMPORTANT: .Show() fires a form load event             Xfrm.BringToFront();          }          public static void ShowXFormInControl(XtraForm Xfrm,              ref XtraPanel ctl, FormBorderStyle style)         {             Xfrm.TopLevel = false;             Xfrm.ControlBox = false;             Xfrm.Parent = ctl;             Xfrm.FormBorderStyle = style;             Xfrm.Left = 0;             Xfrm.Top = 0;             Xfrm.Width = ctl.Width + 4;             Xfrm.Dock = DockStyle.Fill;             Xfrm.Show();             //IMPORTANT: .Show() fires a form load event             Xfrm.BringToFront();          }          public static void ShowFormInControl(Form frm,              ref Panel ctl, FormBorderStyle style)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = 0;                 frm.Top = 0;                 frm.Width = ctl.Width + 4;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }             //.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)         }         public static void ShowFormInControl(Form frm,              ref TabPage ctl, FormBorderStyle style)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = 0;                 frm.Top = 0;                 frm.Width = ctl.Width + 4;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }         }         public static void ShowFormInControl(Form frm,              Panel ctl, FormBorderStyle style, FormWindowState state)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = 0;                 frm.Top = 0;                 frm.Width = ctl.Width + 4;                 frm.WindowState = state;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }             //.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)         }         public static void ShowFormInControl(Form frm,              TabPage ctl, FormBorderStyle style, FormWindowState state)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = 0;                 frm.Top = 0;                 frm.Width = ctl.Width + 4;                 frm.WindowState = state;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }         }         public static void ShowFormInControl(Form frm,              ref Panel ctl, FormBorderStyle style, int left, int top)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = left;                 frm.Top = top;                 frm.Width = ctl.Width + 4;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 //.Activate()                 frm.BringToFront();             }             //.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)         }         public static void ShowFormInControl(Form frm,              ref TabPage ctl, FormBorderStyle style, int left, int top)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = left;                 frm.Top = top;                 frm.Width = ctl.Width + 4;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 //.Activate()                 frm.BringToFront();             }         }         public static void ShowFormInControl(Form frm,              Panel ctl, FormBorderStyle style, int left, int top, string title)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = left;                 frm.Top = top;                 frm.Width = ctl.Width + 4;                 frm.Text = title;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }             //.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)         }         public static void ShowFormInControl(Form frm,              TabPage ctl, FormBorderStyle style, int left, int top, string title)         {             {                 frm.TopLevel = false;                 frm.ControlBox = false;                 frm.Parent = ctl;                 frm.FormBorderStyle = style;                 frm.Left = left;                 frm.Top = top;                 frm.Width = ctl.Width + 4;                 frm.Text = title;                 frm.Dock = DockStyle.Fill;                 frm.Show();                 //IMPORTANT: .Show() fires a form load event                 frm.BringToFront();             }         }     } } 

I have the darnedest time posting code here and it turning out looking decent!

  • 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. 2026-05-11T06:19:26+00:00Added an answer on May 11, 2026 at 6:19 am

    You don’t need generic to do this:

    public static void ShowFormInControl(Control ctl, Form frm) {   frm.TopLevel = false;   frm.FormBorderStyle = FormBorderStyle.None;  // Others rarely make sense   frm.Dock = DockStyle.Fill;   frm.Visible = true;   ctl.Controls.Add(frm); } 

    Sample usage:

    public Form1() {   InitializeComponent();   ShowFormInControl(this.panel1, new Form2()); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer What about using the Cookie plugin for jQuery? $.cookie('the_cookie', 'the_value');… May 11, 2026 at 1:39 pm
  • added an answer I think what you've done is fine. I would only… May 11, 2026 at 1:39 pm
  • added an answer If worst comes to worst, you could omit the ENCODING… May 11, 2026 at 1:39 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.