c# - A partial class has multiple form -


When I write a winforms application, I use an Implementation.cs file for each form Make them.

I think is Form1.cs , I have a new file named Form1.Implementation.cs for the partial category form 1 I would like to get started with .

Form1.cs contains all the event callback methods (what the designer has done), everything else Form1.Implementation.cs . It helps me write more readable code. Form1.Implementation.cs is the "subfile" Em> like Form1.Designer.cs , so I've edited the .csproj file .

  & lt; Include compilation = "Form1.implementation.cs" & gt; & Lt; DependentUpon & gt; Form1.cs & lt; / DependentUpon & gt; & Lt; / Compiled & gt;   

After reloading, Visual Studio will automatically dependence & lt; Subtype & gt; Form & lt; / Subtype & gt; The element does not show the double clicking Form1.Implementation.cs code but a designer with an initial blank form.

Like it

"class form1 , which is the ISA form , (?) Multiple forms "

I tried the form 1 class, but it also affects Form1.cs .

OK, killing 'Shift-F7' or 'Ctrl-Shift-0' is not a big deal. I'm surprised that ...

  1. This is a mess of visual studio ,
  2. The secondary (?) Form actually exists in some way,
  3. This is about to blow my explosive project at any time

    The only way you can try the & lt; Dependenton & gt; By adding , which you already know, Visual Studio will automatically have & lt; Subtype & gt; Form and lt; / Subtype & gt; Adds because in your Form1.cs , the line is in line with the public partial class form 1: form , this is where the subtype is coming from.

    Other files - Form1.Designer.cs and Form1.Implementation.cs should only contain Part 1 of the form part But since partial category definitions have multiple files still in effect, the definition of a class, Visual Studio detects that it still handles it, I believe you already know, but only in this matter. Do not worry if there are many instances in this scenario. Remember this is still a class - Form1 , there is no information about how many files you spread.

    Finally, all code files are (even partial!) Inheritance (or) automatically opened in the designer. This behavior is by design.

    The solution here is simple - either make a code defining a different code, which is not on the basis, or just use F7 to view the file's code solution in Explorer It seems annoying. It does not matter whether the code file and

  4. dependent is nothing but not only heritage or matters.

    The best solution, however, in my opinion, what the studio is giving you is to stick to it:

    • Designer-generated code remains Form1 Designer.cs
    • Go to Form1.cs (Designer) in your code (which you put in Implementation ) Instead of pressing F7 to see that code)

      This is an attitude that my team is sticking for some years now. This designer code provides a basic means of separation of hand coded actions. To better detach your code, use design patterns such as MVP, as suggested by suggestions by Simon Whitehead.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -