Breaking Forms in to partial classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rene

    #1

    Breaking Forms in to partial classes

    VS 2005 uses the Partial Class & <form>.Designer .cs for its windows forms
    generated code.

    When upgrading from 2003 the project wizard did not break the form, it left
    it the old way. I would like to split them. Who the heck do you do that?
    Other than using the IDE and add a new Form, I was not able to insert the
    partial Form class in the nice hierarchical way the IDE does it. How do you
    do that?

    Thanks.


  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Breaking Forms in to partial classes

    Hi,

    AFAIK there is no way of doing it. It would be nice though.

    cheers,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation



    "Rene" <nospam@nospam. com> wrote in message
    news:OtquvngAGH A.2356@tk2msftn gp13.phx.gbl...[color=blue]
    > VS 2005 uses the Partial Class & <form>.Designer .cs for its windows forms
    > generated code.
    >
    > When upgrading from 2003 the project wizard did not break the form, it
    > left it the old way. I would like to split them. Who the heck do you do
    > that? Other than using the IDE and add a new Form, I was not able to
    > insert the partial Form class in the nice hierarchical way the IDE does
    > it. How do you do that?
    >
    > Thanks.
    >
    >[/color]


    Comment

    • Richard Grimes

      #3
      Re: Breaking Forms in to partial classes

      Rene wrote:[color=blue]
      > VS 2005 uses the Partial Class & <form>.Designer .cs for its windows
      > forms generated code.
      >
      > When upgrading from 2003 the project wizard did not break the form,
      > it left it the old way. I would like to split them. Who the heck do
      > you do that? Other than using the IDE and add a new Form, I was not
      > able to insert the partial Form class in the nice hierarchical way
      > the IDE does it. How do you do that?[/color]

      Edit the csproj file by hand?

      for example, for Form1.cs I find these entries:

      <Compile Include="Form1. cs">
      <Subtype>Form<S ubtype>
      </Compile>
      <Compile Include="Form1. Designer.cs">
      <DependentUpon> Form1.cs</DependentUpon>
      </Compile>

      I took a VS2003 form file and separate it out into two partial classes
      (putting InitializeCompo nent and Dispose in Form2.Designer. cs). Then
      (with the solution closed) I copied the lines above and replaced Form1
      with the name of my C# file(s) and everything worked.

      Richard
      --
      Fusion Tutorial: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
      Security Tutorial:



      Comment

      • Rene

        #4
        Re: Breaking Forms in to partial classes

        Thanks Richard .

        Hmmmm.... Now if I could only figure out why they decided to put the
        InitializeCompo nent() in the From class instead of the Designer class......





        "Richard Grimes" <richardg@mvps. org> wrote in message
        news:us3TUQ1AGH A.3340@tk2msftn gp13.phx.gbl...[color=blue]
        > Rene wrote:[color=green]
        >> VS 2005 uses the Partial Class & <form>.Designer .cs for its windows
        >> forms generated code.
        >>
        >> When upgrading from 2003 the project wizard did not break the form,
        >> it left it the old way. I would like to split them. Who the heck do
        >> you do that? Other than using the IDE and add a new Form, I was not
        >> able to insert the partial Form class in the nice hierarchical way
        >> the IDE does it. How do you do that?[/color]
        >
        > Edit the csproj file by hand?
        >
        > for example, for Form1.cs I find these entries:
        >
        > <Compile Include="Form1. cs">
        > <Subtype>Form<S ubtype>
        > </Compile>
        > <Compile Include="Form1. Designer.cs">
        > <DependentUpon> Form1.cs</DependentUpon>
        > </Compile>
        >
        > I took a VS2003 form file and separate it out into two partial classes
        > (putting InitializeCompo nent and Dispose in Form2.Designer. cs). Then (with
        > the solution closed) I copied the lines above and replaced Form1 with the
        > name of my C# file(s) and everything worked.
        >
        > Richard
        > --
        > Fusion Tutorial: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
        > Security Tutorial:
        > http://www.grimes.demon.co.uk/workshops/securityWS.htm
        >[/color]


        Comment

        Working...