Move Form to Namespace (VB 2005)

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

    #1

    Move Form to Namespace (VB 2005)

    Hi all,

    I have a Form called "Main":

    Public Class Main

    Private Sub Button1_Click( _
    ByVal sender As System.Object, ByVal e As System.EventArg s) _
    Handles Button1.Click

    End Sub

    End Class


    Now I want to put the form into a namespace called "Forms". If I put the
    lines "Namespace Forms" and "end namespace" before and after the code above,
    I get an error at the "Handles" clause. Reason: The "Partial Class" in
    Main.Designer.v b is still in the old Namespace. Consequently the class in
    Main.vb is a different class not having any buttons anymore, therefore the
    error.

    Now I could manually also put the whole "Partial Class" into the "Forms"
    namespace, but as the file is "designer generated" I can not touch it (or
    take the risk that my lines will be overwritten).

    So, how do I move a Form into a namespace in VB 2005? This was no problem in
    VB 2003 because it was all one file.


    Armin

  • Tom Shelton

    #2
    Re: Move Form to Namespace (VB 2005)

    On 2007-02-11, Armin Zingler <az.nospam@free net.dewrote:
    Hi all,
    >
    I have a Form called "Main":
    >
    Public Class Main
    >
    Private Sub Button1_Click( _
    ByVal sender As System.Object, ByVal e As System.EventArg s) _
    Handles Button1.Click
    >
    End Sub
    >
    End Class
    >
    >
    Now I want to put the form into a namespace called "Forms". If I put the
    lines "Namespace Forms" and "end namespace" before and after the code above,
    I get an error at the "Handles" clause. Reason: The "Partial Class" in
    Main.Designer.v b is still in the old Namespace. Consequently the class in
    Main.vb is a different class not having any buttons anymore, therefore the
    error.
    >
    Now I could manually also put the whole "Partial Class" into the "Forms"
    namespace, but as the file is "designer generated" I can not touch it (or
    take the risk that my lines will be overwritten).
    >
    So, how do I move a Form into a namespace in VB 2005? This was no problem in
    VB 2003 because it was all one file.
    >
    >
    Armin
    Just change it and make your default namespace the new namespace. You should
    have a problem with it... At least, I haven't in c# :)

    --
    Tom Shelton

    Comment

    • Armin Zingler

      #3
      Re: Move Form to Namespace (VB 2005)

      "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne tschrieb
      On 2007-02-11, Armin Zingler <az.nospam@free net.dewrote:
      Hi all,

      I have a Form called "Main":

      Public Class Main

      Private Sub Button1_Click( _
      ByVal sender As System.Object, ByVal e As
      System.EventArg s) _ Handles Button1.Click

      End Sub

      End Class


      Now I want to put the form into a namespace called "Forms". If I
      put the lines "Namespace Forms" and "end namespace" before and
      after the code above, I get an error at the "Handles" clause.
      Reason: The "Partial Class" in Main.Designer.v b is still in the
      old Namespace. Consequently the class in Main.vb is a different
      class not having any buttons anymore, therefore the error.

      Now I could manually also put the whole "Partial Class" into the
      "Forms" namespace, but as the file is "designer generated" I can
      not touch it (or take the risk that my lines will be overwritten).

      So, how do I move a Form into a namespace in VB 2005? This was no
      problem in VB 2003 because it was all one file.


      Armin
      >
      Just change it and make your default namespace the new namespace.
      You should have a problem with it... At least, I haven't in c# :)
      Uhm, sorry, but I don't understand. What should I change? The designer
      generated file? Why should I have a problem with it? I don't want to change
      the default namespace (you mean the root namespace of the project?), I only
      want to put the Form in the Namespace.


      Armin

      Comment

      • Patrick Steele

        #4
        Re: Move Form to Namespace (VB 2005)

        In article <OyME18XTHHA.40 76@TK2MSFTNGP05 .phx.gbl>, az.nospam@freen et.de
        says...
        Now I want to put the form into a namespace called "Forms". If I put the
        lines "Namespace Forms" and "end namespace" before and after the code above,
        I get an error at the "Handles" clause. Reason: The "Partial Class" in
        Main.Designer.v b is still in the old Namespace. Consequently the class in
        Main.vb is a different class not having any buttons anymore, therefore the
        error.
        >
        Now I could manually also put the whole "Partial Class" into the "Forms"
        namespace, but as the file is "designer generated" I can not touch it (or
        take the risk that my lines will be overwritten).
        I've done this before (in C#) and never had a problem with VS.NET
        messing up my namespace declaration in the Main.Designer.c s file after
        editing the form.

        --
        Patrick Steele

        Comment

        • Michael D. Ober

          #5
          Re: Move Form to Namespace (VB 2005)

          You need to right click your solution and select view hidden files. Now you
          can see and edit the designer files. The issue you are running up against
          is that the VB IDE creates "default" namespaces.

          Mike Ober.

          "Patrick Steele" <patrick@mvps.o rgwrote in message
          news:MPG.20399d 1932e6c5e49896f 6@msnews.micros oft.com...
          In article <OyME18XTHHA.40 76@TK2MSFTNGP05 .phx.gbl>, az.nospam@freen et.de
          says...
          >Now I want to put the form into a namespace called "Forms". If I put the
          >lines "Namespace Forms" and "end namespace" before and after the code
          >above,
          >I get an error at the "Handles" clause. Reason: The "Partial Class" in
          >Main.Designer. vb is still in the old Namespace. Consequently the class in
          >Main.vb is a different class not having any buttons anymore, therefore
          >the
          >error.
          >>
          >Now I could manually also put the whole "Partial Class" into the "Forms"
          >namespace, but as the file is "designer generated" I can not touch it (or
          >take the risk that my lines will be overwritten).
          >
          I've done this before (in C#) and never had a problem with VS.NET
          messing up my namespace declaration in the Main.Designer.c s file after
          editing the form.
          >
          --
          Patrick Steele
          http://weblogs.asp.net/psteele


          Comment

          • Tom Shelton

            #6
            Re: Move Form to Namespace (VB 2005)

            On 2007-02-11, Armin Zingler <az.nospam@free net.dewrote:
            "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne tschrieb
            >On 2007-02-11, Armin Zingler <az.nospam@free net.dewrote:
            Hi all,
            >
            I have a Form called "Main":
            >
            Public Class Main
            >
            Private Sub Button1_Click( _
            ByVal sender As System.Object, ByVal e As
            System.EventArg s) _ Handles Button1.Click
            >
            End Sub
            >
            End Class
            >
            >
            Now I want to put the form into a namespace called "Forms". If I
            put the lines "Namespace Forms" and "end namespace" before and
            after the code above, I get an error at the "Handles" clause.
            Reason: The "Partial Class" in Main.Designer.v b is still in the
            old Namespace. Consequently the class in Main.vb is a different
            class not having any buttons anymore, therefore the error.
            >
            Now I could manually also put the whole "Partial Class" into the
            "Forms" namespace, but as the file is "designer generated" I can
            not touch it (or take the risk that my lines will be overwritten).
            >
            So, how do I move a Form into a namespace in VB 2005? This was no
            problem in VB 2003 because it was all one file.
            >
            >
            Armin
            >>
            >Just change it and make your default namespace the new namespace.
            >You should have a problem with it... At least, I haven't in c# :)
            >
            Uhm, sorry, but I don't understand. What should I change? The designer
            generated file?
            Yes. Just change the namespace declaration in the designer file.
            Why should I have a problem with it?
            I meant you should not have a problem. It was a typo.
            I don't want to change
            the default namespace (you mean the root namespace of the project?), I only
            want to put the Form in the Namespace.
            I see, you already changed it and you are moving the form into it... Then just
            change the designer file. It shouldn't cause any issues.

            --
            Tom Shelton

            Comment

            • Armin Zingler

              #7
              Re: Move Form to Namespace (VB 2005)

              "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne tschrieb
              Just change it and make your default namespace the new
              namespace. You should have a problem with it... At least, I
              haven't in c# :)
              Uhm, sorry, but I don't understand. What should I change? The
              designer generated file?
              >
              Yes. Just change the namespace declaration in the designer file.
              >
              Why should I have a problem with it?
              >
              I meant you should not have a problem. It was a typo.
              Ah, I see.
              >I don't want to change
              >the default namespace (you mean the root namespace of the project?), I
              >only
              >want to put the Form in the Namespace.
              >
              I see, you already changed it and you are moving the form into it... Then
              just
              change the designer file. It shouldn't cause any issues.
              Ok, I'll try.

              Thanks Tom.


              Armin

              Comment

              • Armin Zingler

                #8
                Re: Move Form to Namespace (VB 2005)

                "Patrick Steele" <patrick@mvps.o rgschrieb
                In article <OyME18XTHHA.40 76@TK2MSFTNGP05 .phx.gbl>,
                az.nospam@freen et.de says...
                Now I want to put the form into a namespace called "Forms". If I
                put the lines "Namespace Forms" and "end namespace" before and
                after the code above, I get an error at the "Handles" clause.
                Reason: The "Partial Class" in Main.Designer.v b is still in the
                old Namespace. Consequently the class in Main.vb is a different
                class not having any buttons anymore, therefore the error.

                Now I could manually also put the whole "Partial Class" into the
                "Forms" namespace, but as the file is "designer generated" I can
                not touch it (or take the risk that my lines will be overwritten).
                >
                I've done this before (in C#) and never had a problem with VS.NET
                messing up my namespace declaration in the Main.Designer.c s file
                after editing the form.
                Ok, seems to be save. I'll try it.

                Thanks Patrick.


                Armin

                Comment

                Working...