richzilla
richzilla

Reputation: 42062

Where is the rest of my windows form code

Looking at the source code for a windows form application, the class declaration states its a partial class. I understand that this means there are parts of the class in different physical files.

The code in MyForm.designer.cs doesnt appear to have a constructor or any means of generating the form. So my question is, where do i find the rest of the code for my windows form?

Upvotes: 2

Views: 156

Answers (5)

sobby01
sobby01

Reputation: 2164

Using Partial keyword code can be reside in multiple classes.When you add a window form that creates three files 1. Code file(.CS) 2. Designer file(.Designer.cs) 3. Your Design part. All used Partial keyword. If you want to see code then double click on design form you will direct to code file there you can find the code and you can handle all the code and events(Developer's Code) like constructor and all. In Designer.cs you initialize the controls their control properties.It's system generated code but still you can modify.

Hope this helps.....

Upvotes: 0

RvdK
RvdK

Reputation: 19800

MyForm.cs has the constructor and MyForm.designer.cs has the function private void InitializeComponent() which will be called from the constructor (in MyForm.cs).

In private void InitializeComponent() your components will be created and initialized.

Upvotes: 0

SLaks
SLaks

Reputation: 888233

Use the View Code option to see the actual source of MyForm.cs, which has a constructor as well as all of your code.

Upvotes: 0

user153498
user153498

Reputation:

The constructor for MyForm is in the main MyForm.cs file. Because it is partial, the constructor can reside in MyForm.cs, and the generated code can stay in MyForm.Designer.cs, allowing for separation of generated and developer-created code.

Upvotes: 7

capdragon
capdragon

Reputation: 14899

Double click on the form will take you there.

Upvotes: -1

Related Questions