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 8393637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:50:53+00:00 2026-06-09T19:50:53+00:00

All, I’m using MSVS 2010 doing a project with C#/WinForms. I made an object

  • 0

All,

I’m using MSVS 2010 doing a project with C#/WinForms.
I made an object derived from the group box and I changed it’s constructor so that it will take an integer variable on construction.
I added my object to the toolbox and I can successfully insert that object on the GUI designer.

But every time I make a change in the form my custom constructor is changed.

So I need a way to either fix VS so that every time I changed a form the code won’t rebuild itself or I need some other way of fixing the code in my custom made object.

Basically what I am doing is depending on the parameter I passed I am creating different set of the widgets and show them to the user. But I made that object because I am trying to eliminate the code repetition.

Could someone please help?

Thank you.

  • 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-09T19:50:55+00:00Added an answer on June 9, 2026 at 7:50 pm

    The default no-arg constructor must be left in and it should call InitializeComponents. If that is done, then adding a secondary constructor should be OK and designer should not mess with it.

    However, I would recommend not using overloaded constructors, but rather exposing Methods or Properties to accomplish the desired task for a WinForms control.

    When in WinRome, do as the..


    Example of secondary constructor:

    // Leave this constructor - in the X.designer.cs file
    public MyType () {
        InitializeComponents();
    }
    
    // Add your own constructor - in the X.cs file
    public MyType (int x) : this() {
        // ..
    }
    

    Update: avoiding editing the “X.designer.cs” files by hand; these are for the designer. Instead, edit the mirroring “X.cs” file. Partial classes are used to spread up the designer code and your custom code between these two files.

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

Sidebar

Related Questions

All, I'm inserting some text from a textarea in a mySQL database. I'm using
All, If I run a query like the following: $qry = Select wrong_column from
All, How can I bind the array of drop down list items returned from
All programs that I develop utilize the default Windows Design template: Besides from changing
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
All, I am building a small site using PHP. In the site, I receive
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
All the code/commands below are part of a PHP script that processes images from

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.