Stop Designer from popping up on a .cs file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael A. Covington

    Stop Designer from popping up on a .cs file?

    I had a lot of code in Form1.cs, so I moved some of it into another file,
    Form1Op.cs, which is still a partial class of Form1 : Form.

    Whenever I open Form1Op.cs, it wants to open in Form Designer rather than in
    View Code. How can I change that? (Or can I?)

    It compiles fine.

  • Jeff Johnson

    #2
    Re: Stop Designer from popping up on a .cs file?

    "Michael A. Covington" <mc@uga.eduwrot e in message
    news:%23Lc0cagO JHA.2292@TK2MSF TNGP04.phx.gbl. ..
    >I had a lot of code in Form1.cs, so I moved some of it into another file,
    >Form1Op.cs, which is still a partial class of Form1 : Form.
    >
    Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
    in View Code. How can I change that? (Or can I?)
    I doubt it. Think about it. The code in Form1.cs is more than likely just
    functional code, not the stuff that defines the UI (that's in
    Form1.Designer. cs), but what happens when you double-click on Form1? The
    designer opens. It would be kind of nice if the IDE would open the designer
    only when you double-click the .Designer file and open everything else in
    code mode, but I'm sure as many people would complain about that as would
    enjoy it.


    Comment

    • Mel Weaver

      #3
      Re: Stop Designer from popping up on a .cs file?

      If you are talking about when you double click on the file name in Solution
      Explorer, just right click and view code.

      "Jeff Johnson" <i.get@enough.s pamwrote in message
      news:%23XYW%23i gOJHA.584@TK2MS FTNGP06.phx.gbl ...
      "Michael A. Covington" <mc@uga.eduwrot e in message
      news:%23Lc0cagO JHA.2292@TK2MSF TNGP04.phx.gbl. ..
      >
      >>I had a lot of code in Form1.cs, so I moved some of it into another file,
      >>Form1Op.cs, which is still a partial class of Form1 : Form.
      >>
      >Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
      >in View Code. How can I change that? (Or can I?)
      >
      I doubt it. Think about it. The code in Form1.cs is more than likely just
      functional code, not the stuff that defines the UI (that's in
      Form1.Designer. cs), but what happens when you double-click on Form1? The
      designer opens. It would be kind of nice if the IDE would open the
      designer only when you double-click the .Designer file and open everything
      else in code mode, but I'm sure as many people would complain about that
      as would enjoy it.
      >

      Comment

      • Jeff Johnson

        #4
        Re: Stop Designer from popping up on a .cs file?

        "Mel Weaver" <MelRemoveSpam@ Insdirect.comwr ote in message
        news:OFd%233lgO JHA.3980@TK2MSF TNGP06.phx.gbl. ..
        If you are talking about when you double click on the file name in
        Solution Explorer, just right click and view code.
        Yes, of course, but I assumed the poster was talking about the "default"
        action, i.e., what happens when you double-click, not that he HAD to open it
        in Design view and then switch to Code view from there.


        Comment

        • MC

          #5
          Re: Stop Designer from popping up on a .cs file?

          "Jeff Johnson" <i.get@enough.s pamwrote in message news:%23uZZFIhO JHA.4760@TK2MSF TNGP02.phx.gbl. ..
          "Mel Weaver" <MelRemoveSpam@ Insdirect.comwr ote in message
          news:OFd%233lgO JHA.3980@TK2MSF TNGP06.phx.gbl. ..

          >If you are talking about when you double click on the file name in
          >Solution Explorer, just right click and view code.
          Yes, of course, but I assumed the poster was talking about the "default"
          action, i.e., what happens when you double-click, not that he HAD to open it
          in Design view and then switch to Code view from there.
          Right; I was hoping I could find something to put in the file to keep Designer from thinking it's a form. Also, I'm afraid of corrupting Form1.Designer. cs by running Designer on the wrong code file -- although the way they're named, that shouldn't happen.

          Comment

          • Frans Bouma [C# MVP]

            #6
            Re: Stop Designer from popping up on a .cs file?

            Michael A. Covington wrote:
            I had a lot of code in Form1.cs, so I moved some of it into another
            file, Form1Op.cs, which is still a partial class of Form1 : Form.
            >
            Whenever I open Form1Op.cs, it wants to open in Form Designer rather
            than in View Code. How can I change that? (Or can I?)
            >
            It compiles fine.
            Every IComponent implementing class has this behavior: it will force
            vs.net to open the designer for the type of class.

            You can disable this by annotating the class with an attribute. After
            that, you can double click it and code is shown. Be sure to type the
            full namespace in the attribute even though it's in the using blocks.
            attribute to use on the class:
            [System.Componen tModel.Designer Category("Code" )]

            Haven't tested it on a form, but IMHO it should work.

            FB

            --
            ------------------------------------------------------------------------
            Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
            LLBLGen Pro website: http://www.llblgen.com
            My .NET blog: http://weblogs.asp.net/fbouma
            Microsoft MVP (C#)
            ------------------------------------------------------------------------

            Comment

            • Jesse Houwing

              #7
              Re: Stop Designer from popping up on a .cs file?

              Hello mc,
              "Jeff Johnson" <i.get@enough.s pamwrote in message
              news:%23uZZFIhO JHA.4760@TK2MSF TNGP02.phx.gbl. ..
              >
              >"Mel Weaver" <MelRemoveSpam@ Insdirect.comwr ote in message
              >news:OFd%233lg OJHA.3980@TK2MS FTNGP06.phx.gbl ...
              >>
              >>If you are talking about when you double click on the file name in
              >>Solution Explorer, just right click and view code.
              >>>
              >Yes, of course, but I assumed the poster was talking about the
              >"default" action, i.e., what happens when you double-click, not that
              >he HAD to open it in Design view and then switch to Code view from
              >there.
              >>
              Right; I was hoping I could find something to put in the file to keep
              Designer from thinking it's a form. Also, I'm afraid of corrupting
              Form1.Designer. cs by running Designer on the wrong code file --
              although the way they're named, that shouldn't happen.
              even if you open your Form1Op.cs, the designer will still write all its stuff
              to the .designer.cs file, so no worries there...


              --
              Jesse Houwing
              jesse.houwing at sogeti.nl


              Comment

              • MC

                #8
                Re: Stop Designer from popping up on a .cs file?

                "Frans Bouma [C# MVP]" <perseus.usenet NOSPAM@xs4all.n lwrote in message news:Oa9RoxmOJH A.4760@TK2MSFTN GP02.phx.gbl...

                Every IComponent implementing class has this behavior: it will force
                vs.net to open the designer for the type of class.

                You can disable this by annotating the class with an attribute. After
                that, you can double click it and code is shown. Be sure to type the
                full namespace in the attribute even though it's in the using blocks.
                attribute to use on the class:
                [System.Componen tModel.Designer Category("Code" )]

                Haven't tested it on a form, but IMHO it should work.
                Thanks -- if it works, that's exactly what I was looking for.

                Comment

                • Jeff Johnson

                  #9
                  Re: Stop Designer from popping up on a .cs file?

                  "Frans Bouma [C# MVP]" <perseus.usenet NOSPAM@xs4all.n lwrote in message
                  news:Oa9RoxmOJH A.4760@TK2MSFTN GP02.phx.gbl...
                  You can disable this by annotating the class with an attribute. After
                  that, you can double click it and code is shown. Be sure to type the full
                  namespace in the attribute even though it's in the using blocks.
                  attribute to use on the class:
                  [System.Componen tModel.Designer Category("Code" )]
                  Holy crap, I'm putting this in EVERY service I've ever written right now!!


                  Comment

                  • Jeff Johnson

                    #10
                    Re: Stop Designer from popping up on a .cs file?

                    "Jeff Johnson" <i.get@enough.s pamwrote in message
                    news:O8jXOKpOJH A.4328@TK2MSFTN GP02.phx.gbl...
                    >You can disable this by annotating the class with an attribute. After
                    >that, you can double click it and code is shown. Be sure to type the full
                    >namespace in the attribute even though it's in the using blocks.
                    >attribute to use on the class:
                    >[System.Componen tModel.Designer Category("Code" )]
                    >
                    Holy crap, I'm putting this in EVERY service I've ever written right now!!
                    Didn't work for services.


                    Comment

                    • Chris Dunaway

                      #11
                      Re: Stop Designer from popping up on a .cs file?

                      On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwr ote:
                      I had a lot of code in Form1.cs, so I moved some of it into another file,
                      Form1Op.cs, which is still a partial class of Form1 : Form.
                      >
                      Whenever I open Form1Op.cs, it wants to open in Form Designer rather than in
                      View Code. How can I change that? (Or can I?)
                      >
                      It compiles fine.
                      Can you right click on the file in question, choose Open With....
                      Then select the code editor and click the "Set as Default" button.
                      Thereafter, when you double click the file, it should open in the code
                      editor.

                      Chris

                      Comment

                      • Jeff Johnson

                        #12
                        Re: Stop Designer from popping up on a .cs file?

                        "Chris Dunaway" <dunawayc@gmail .comwrote in message
                        news:53fd92fa-e11b-4c91-89bf-4ee7f5b33bf8@e2 g2000hsh.google groups.com...
                        >I had a lot of code in Form1.cs, so I moved some of it into another file,
                        >Form1Op.cs, which is still a partial class of Form1 : Form.
                        >>
                        >Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
                        >in
                        >View Code. How can I change that? (Or can I?)
                        >>
                        >It compiles fine.
                        >
                        Can you right click on the file in question, choose Open With....
                        Then select the code editor and click the "Set as Default" button.
                        Thereafter, when you double click the file, it should open in the code
                        editor.
                        I don't know about Michael's issue, but that certainly worked for my
                        services!! Thanks a bunch!


                        Comment

                        • Michael A. Covington

                          #13
                          Re: Stop Designer from popping up on a .cs file?


                          "MC" <for.address.lo ok@www.ai.uga.e du.slash.mcwrot e in message
                          news:OmoTGDpOJH A.4332@TK2MSFTN GP06.phx.gbl...
                          "Frans Bouma [C# MVP]" <perseus.usenet NOSPAM@xs4all.n lwrote in message
                          news:Oa9RoxmOJH A.4760@TK2MSFTN GP02.phx.gbl...
                          >
                          >Every IComponent implementing class has this behavior: it will force
                          >vs.net to open the designer for the type of class.
                          >>
                          >You can disable this by annotating the class with an attribute. After
                          >that, you can double click it and code is shown. Be sure to type the
                          >full namespace in the attribute even though it's in the using blocks.
                          >attribute to use on the class:
                          >[System.Componen tModel.Designer Category("Code" )]
                          >>
                          >Haven't tested it on a form, but IMHO it should work.
                          >
                          Thanks -- if it works, that's exactly what I was looking for.
                          >
                          It stops Designer from working on Form1 at all. I was only wanting to stop
                          Designer from working on one of the files that is a partial class Form1.
                          For now, I gave up on splitting Form1 into partial classes and moved the
                          code back into Form1.cs as a region.

                          Comment

                          • Michael A. Covington

                            #14
                            Re: Stop Designer from popping up on a .cs file?


                            "Chris Dunaway" <dunawayc@gmail .comwrote in message
                            news:53fd92fa-e11b-4c91-89bf-4ee7f5b33bf8@e2 g2000hsh.google groups.com...
                            On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwr ote:
                            >I had a lot of code in Form1.cs, so I moved some of it into another file,
                            >Form1Op.cs, which is still a partial class of Form1 : Form.
                            >>
                            >Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
                            >in
                            >View Code. How can I change that? (Or can I?)
                            >>
                            >It compiles fine.
                            >
                            Can you right click on the file in question, choose Open With....
                            Then select the code editor and click the "Set as Default" button.
                            Thereafter, when you double click the file, it should open in the code
                            editor.
                            *duh!* yes... that sounds like exactly what is needed. Thanks.

                            Comment

                            • Michael A. Covington

                              #15
                              Re: Stop Designer from popping up on a .cs file?


                              "Michael A. Covington" <mc@uga.eduwrot e in message
                              news:eqwGAWrOJH A.1172@TK2MSFTN GP03.phx.gbl...
                              >
                              "Chris Dunaway" <dunawayc@gmail .comwrote in message
                              news:53fd92fa-e11b-4c91-89bf-4ee7f5b33bf8@e2 g2000hsh.google groups.com...
                              >On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwr ote:
                              >>I had a lot of code in Form1.cs, so I moved some of it into another
                              >>file,
                              >>Form1Op.cs, which is still a partial class of Form1 : Form.
                              >>>
                              >>Whenever I open Form1Op.cs, it wants to open in Form Designer rather
                              >>than in
                              >>View Code. How can I change that? (Or can I?)
                              >>>
                              >>It compiles fine.
                              >>
                              >Can you right click on the file in question, choose Open With....
                              >Then select the code editor and click the "Set as Default" button.
                              >Thereafter, when you double click the file, it should open in the code
                              >editor.
                              >
                              *duh!* yes... that sounds like exactly what is needed. Thanks.
                              And it isn't. Even THAT won't let me set different default behavior for 2
                              different files that are partial classes of the same class. Ah well...


                              Comment

                              Working...