Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create designer.cs file (c#)

Posted on 2006-10-23
14
Medium Priority
?
2,898 Views
Last Modified: 2007-12-19
Hi experts,

I converted a C# .net 2003 application to .net 2005... but the conversion has not created the *.Designer.cs file for the forms. Now i would like to export the "generated codes" to that designer file. There is any tools (or else) which let me do that?!?!

Any help would be appreciate.

Mart.
0
Comment
Question by:pmrenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
14 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 17788716
You can do this manually: create *.Designer.cs file and add it to the project. Move all designer-generated code there. Declare class as partial in both files. You can create new Windows application program to see what is *.Designer.cs file structure. It contains the following parts:
components variable declaration,
Dispose method,
InitializeComponent function in the "Windows Form Designer generated code" region,
Control members.

namespace WindowsApplication1
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(78, 85);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(130, 33);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;
    }
}

There are no hidden features in *.Designer.cs file, if you create it as designer expects, it will work.
0
 

Author Comment

by:pmrenaud
ID: 17789159
I created the Dispose routine and i got this error:
Error      1      'src.com.laubrass.stataudit.view.MainScreen.Dispose(bool)': no suitable method found to override

what's wrong?!?

thks
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17789310
Is class derived from Form class? In Wizard-generated application we can see:

Form1.cs:

    public partial class Form1 : Form
    {
    }

Form1.Designer.cs:

    partial class Form1
    {
    }

Can you post here code in both files?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pmrenaud
ID: 17789361
Hi again,

in fact, we have now two classes: one for the form.cs and an other one for form.designer.cs. In the View class diagram, i see two diagrams, not only one. And obviously, during the debugging, i have errors... because each of them are not able to see the other one.

thks
0
 

Author Comment

by:pmrenaud
ID: 17789387
Here is what i have..

MainScreen.cs:

public partial class MainScreen: Form
{
}

MainScreen.Designer.cs:

 partial class MainScreen
{
}
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17789435
Can you post code here? Maybe without unnecessary event handlers and functions in MainScreen.cs. Something that I can reproduce and test.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17789465
I made small test: created Windows Forms application and removed Form1 from it. Then I added new empty Form1.cs and Form1.Designer.cs files to the project, and pasted code from other application. It works OK. Your code has some syntax error. Maybe two classes belong to different namespaces?
0
 

Author Comment

by:pmrenaud
ID: 17789996
Well...

the forms have been created in C# .Net 2003 and have been "converted" into C# .Net 2005. The convertion has not create the *.Designer.cs file...

i'm going to try the creation of the designer file one more time... and i get back!

thks
0
 

Author Comment

by:pmrenaud
ID: 17790477
We've found the problem, there was a typo in one of the two namespace definitions.

(shame on me!!!)

0
 
LVL 48

Expert Comment

by:AlexFM
ID: 17964511
I think the question is answered.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 18034783
Again, I think that question is answered and questioner followed my solution.
0
 

Author Comment

by:pmrenaud
ID: 18036341
thks for answers... sorry for delay...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question