Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. button event handler where it drops it?

button event handler where it drops it?

Scheduled Pinned Locked Moved C#
question
14 Posts 4 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G geomeo123

    Is there a way to set where to drop an event handler? When I double click on a button it drops mine at line 1500 for some reason. Then I have to cut and paste. It's doing it in a region of code and it expands that region, which is a little annoying. I'm hoping to drop at the top somewhere, possible?

    OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #2

    Annoying, isn't it? I've never found a solution to that either, and I've been using VS for 15 years ...

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    G 1 Reply Last reply
    0
    • G geomeo123

      Is there a way to set where to drop an event handler? When I double click on a button it drops mine at line 1500 for some reason. Then I have to cut and paste. It's doing it in a region of code and it expands that region, which is a little annoying. I'm hoping to drop at the top somewhere, possible?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #3

      You can manually add the handler name to your button in the properties window, and then add the actual handler code wherever you want.

      G 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Annoying, isn't it? I've never found a solution to that either, and I've been using VS for 15 years ...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        G Offline
        G Offline
        geomeo123
        wrote on last edited by
        #4

        YES VERY VERY ANNOYING lol!! Kind of glad I'm not alone! Come on MicroSoft. Geez a whiz. It puts it in a random spot in the middle of nowhere. Where's the add event by line number?? That would make so much sense. Why MicroSoft Whyyyyy??? It would also be nice to apply a static do not expand my code unless I absolutely say so clause. And my last rant of the day is the 3 word line of code that can be simplified warning? Ok it's 3 words how much simpler can it be? I have a few more rants, but I'll table them for another day. Other than that it's a great product. And if I knew someone that was professional at this to tell me where and why's of doing things I would probably rant a lot less. But as it is all I have is Youtube and a lot of books. And nice forums like this one. So let's all be friends and give us our event handler by line number :)!

        OriginalGriffO 1 Reply Last reply
        0
        • L Lost User

          You can manually add the handler name to your button in the properties window, and then add the actual handler code wherever you want.

          G Offline
          G Offline
          geomeo123
          wrote on last edited by
          #5

          Can you explain? You lost me on the word manually? Do you mean manually type it in to the event handler property text box then manually write it to whereever I want? Screenshots would be nice.

          L 1 Reply Last reply
          0
          • G geomeo123

            YES VERY VERY ANNOYING lol!! Kind of glad I'm not alone! Come on MicroSoft. Geez a whiz. It puts it in a random spot in the middle of nowhere. Where's the add event by line number?? That would make so much sense. Why MicroSoft Whyyyyy??? It would also be nice to apply a static do not expand my code unless I absolutely say so clause. And my last rant of the day is the 3 word line of code that can be simplified warning? Ok it's 3 words how much simpler can it be? I have a few more rants, but I'll table them for another day. Other than that it's a great product. And if I knew someone that was professional at this to tell me where and why's of doing things I would probably rant a lot less. But as it is all I have is Youtube and a lot of books. And nice forums like this one. So let's all be friends and give us our event handler by line number :)!

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #6

            geomeo123 wrote:

            Where's the add event by line number?

            Well ... no. Line number isn't helpful, and it's far too easy to add it in the wrong place and get code that doesn't compile - which might be quite difficult to spot! I'd rather have to move it to the right region of the file manually - which isn't hard to do - than have it appear in the middle of an XML comment, or a switch block for example.

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            G 1 Reply Last reply
            0
            • G geomeo123

              Can you explain? You lost me on the word manually? Do you mean manually type it in to the event handler property text box then manually write it to whereever I want? Screenshots would be nice.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              It seems that things have changed since I last did this, and even typing the event name into the event handler, VS automatically adds the handler skeleton at the end of the Form class.

              G 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                geomeo123 wrote:

                Where's the add event by line number?

                Well ... no. Line number isn't helpful, and it's far too easy to add it in the wrong place and get code that doesn't compile - which might be quite difficult to spot! I'd rather have to move it to the right region of the file manually - which isn't hard to do - than have it appear in the middle of an XML comment, or a switch block for example.

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                G Offline
                G Offline
                geomeo123
                wrote on last edited by
                #8

                Quote:

                and it's far too easy to add it in the wrong place and get code that doesn't compile

                That would be pretty impossible. Since any time you click for the eventHandler MicroSoft prompts you exactly where your event code has landed so that you can start writing what you want to do when the event has occurred. I'm fairly sure choosing the line number rather than have that done for us would work.

                1 Reply Last reply
                0
                • L Lost User

                  It seems that things have changed since I last did this, and even typing the event name into the event handler, VS automatically adds the handler skeleton at the end of the Form class.

                  G Offline
                  G Offline
                  geomeo123
                  wrote on last edited by
                  #9

                  Find a program with over 1500 lines of code. It doesn't add to the end of the code anymore. (which would be nice too).

                  1 Reply Last reply
                  0
                  • G geomeo123

                    Is there a way to set where to drop an event handler? When I double click on a button it drops mine at line 1500 for some reason. Then I have to cut and paste. It's doing it in a region of code and it expands that region, which is a little annoying. I'm hoping to drop at the top somewhere, possible?

                    R Offline
                    R Offline
                    Ravi Bhavnani
                    wrote on last edited by
                    #10

                    Where would VS know where to definitively add the handler, other than at the end of the class definition in the first file of the class? :) The code for a Form class could be spread across several files, so this makes identifying a target location harder.  I organize my code in #region elements and have gotten (there - I said it :) ) used to moving the handler to an appropriate location. /ravi

                    My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                    G 1 Reply Last reply
                    0
                    • R Ravi Bhavnani

                      Where would VS know where to definitively add the handler, other than at the end of the class definition in the first file of the class? :) The code for a Form class could be spread across several files, so this makes identifying a target location harder.  I organize my code in #region elements and have gotten (there - I said it :) ) used to moving the handler to an appropriate location. /ravi

                      My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                      G Offline
                      G Offline
                      geomeo123
                      wrote on last edited by
                      #11

                      I don't understand your question?

                      R 1 Reply Last reply
                      0
                      • G geomeo123

                        I don't understand your question?

                        R Offline
                        R Offline
                        Ravi Bhavnani
                        wrote on last edited by
                        #12

                        I was suggesting there's no definitive way for VS to know where to place the new handler. /ravi

                        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                        G 1 Reply Last reply
                        0
                        • R Ravi Bhavnani

                          I was suggesting there's no definitive way for VS to know where to place the new handler. /ravi

                          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                          G Offline
                          G Offline
                          geomeo123
                          wrote on last edited by
                          #13

                          Did you read the entire thread?

                          R 1 Reply Last reply
                          0
                          • G geomeo123

                            Did you read the entire thread?

                            R Offline
                            R Offline
                            Ravi Bhavnani
                            wrote on last edited by
                            #14

                            Yes. /ravi

                            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups