Results 1 to 17 of 17

Thread: [resolved][C# 2.0] Annoying Event Handler Auto-Complete

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved [resolved][C# 2.0] Annoying Event Handler Auto-Complete

    When I add an event handler in Visual Studio 2005 and accept the auto-complete, the method stub looks like this:
    Code:
    this.MouseClick += new MouseEventHandler(Form1_MouseClick);
    
    void Form1_MouseClick(object sender, MouseEventArgs e)
    {
    	throw new Exception("The method or operation is not implemented.");
    }
    Is there a way to stop VS from adding the throw to the function body?
    VS 2003 didn't do this. The method stub was blank.
    Last edited by wey97; Sep 26th, 2006 at 07:31 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2.0] Annoying Event Handler Auto-Complete

    It's there for you to delete when you implement it. Because you'd only subscribe to an event if you meant to implement it.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by mendhak
    It's there for you to delete when you implement it. Because you'd only subscribe to an event if you meant to implement it.
    Damn, mendhak, you should know me well enough to know I knew that.

    I'm just lazy, and I've found it faster to comment out the line than going through the trouble of highlighting the whole line with my mouse and clearing it out. Then I end up with a bunch of trash comments all over the place.

    There should at least be a keyboard shortcut for highlighting an entire line.

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by wey97
    Damn, mendhak, you should know me well enough to know I knew that.

    I'm just lazy, and I've found it faster to comment out the line than going through the trouble of highlighting the whole line with my mouse and clearing it out. Then I end up with a bunch of trash comments all over the place.

    There should at least be a keyboard shortcut for highlighting an entire line.
    With your cursor anywhere on the line you can "Ctrl+Delete" which will cut the entire line. Just make sure you didn't have anything in your clipboard that you wanted.

  5. #5
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2.0] Annoying Event Handler Auto-Complete

    Sorry i meant "shift+delete"

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [2.0] Annoying Event Handler Auto-Complete

    Nice tip. We need a "cool keyboard shortcuts" sticky.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2.0] Annoying Event Handler Auto-Complete

    My favorite is Ctrl+K,C.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by mendhak
    My favorite is Ctrl+K,C.
    I like that one.

    My only complaint about that one or the comment selection toolbar button is it won't insert /* */ comments for a partial line selection like the c++ ide.

  9. #9
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2.0] Annoying Event Handler Auto-Complete

    I like "Ctrl+M,O" and "Ctrl+M,P"

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Annoying Event Handler Auto-Complete

    How about the fact that you can just click the mouse to the far left of the line to select the entire line? The space to do it is fairly small, particularly on lines that have an expansion button, but unless you have a medical problem that affects your fine motor skills it shouldn't be an issue. You'll know you're there because the mouse pointer will turn into a right-pointing arrow instead of a beam or left-pointing arrow.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by jmcilhinney
    How about the fact that you can just click the mouse to the far left of the line to select the entire line? The space to do it is fairly small, particularly on lines that have an expansion button, but unless you have a medical problem that affects your fine motor skills it shouldn't be an issue. You'll know you're there because the mouse pointer will turn into a right-pointing arrow instead of a beam or left-pointing arrow.
    Good point but when you're already typing, it's a pain to have to switch to your mouse and back to typing again.

  12. #12
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Re: [2.0] Annoying Event Handler Auto-Complete

    How about just putting the cursor on the line and hitting crtl+x? It's the easiest key combination to hit and it cuts the entire line since there's no selection.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by DNA7433
    How about just putting the cursor on the line and hitting crtl+x? It's the easiest key combination to hit and it cuts the entire line since there's no selection.
    I just decided to experiment and Shift+Del has the same effect without overwriting the current contents of the clipboard, so it's marginally preferable I guess.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14
    Banned
    Join Date
    Sep 2006
    Posts
    14

    Re: [resolved][C# 2.0] Annoying Event Handler Auto-Complete

    CTRL+E,D is a good one too. (vs 2005 that is, they changed a whole bunch of perfectly good combo's after 2003 for some reason. Also, CTLR+W, S is the solution exomprer and F4 is the properties panel. I often get rid of those 2 windows to give me more code writing space.)

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [resolved][C# 2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by monoptic
    CTRL+E,D is a good one too. (vs 2005 that is, they changed a whole bunch of perfectly good combo's after 2003 for some reason. Also, CTLR+W, S is the solution exomprer and F4 is the properties panel. I often get rid of those 2 windows to give me more code writing space.)
    I use Auto Hide for Solution Explorer and Properties and get just as much space without having to remember a sequence of keys for showing.

  16. #16
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Re: [2.0] Annoying Event Handler Auto-Complete

    Quote Originally Posted by jmcilhinney
    I just decided to experiment and Shift+Del has the same effect without overwriting the current contents of the clipboard, so it's marginally preferable I guess.
    That's an odd one, how in the world did you even think to try that?

    Does MS put out a list of all the shortcuts they have or are the rest of us supposed to stumble upon them?

    Oh, and is there a way to make the dockable windows just appear instead of sliding on screen when you have them auto-hid? Even on my (somewhat) fast computer there's an annoying delay waiting for them to appear.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [resolved][C# 2.0] Annoying Event Handler Auto-Complete

    As I said, I just decided to experiment. The Delete key deletes things and Ctrl, Shift and Alt are modifier keys, so I decided to see how they modified the behaviour of the Delete key.

    As for your last question, Tools -> Options -> Environment -> General -> Animate environment tools. The Options dialogue is the first place to look whenever you want to change the behaviour of the IDE. I didn't know about that setting myself but I just opened the Options dialogue and there it was.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width