none
Visual C# quick reference to control methods and events RRS feed

  • Question

  • Fellow coders,

    I am searching for a good quick reference book(s) for VS C# controls methods and events. I've searched the forums thoroughly and all of the various reference books I have found (and there are ZILLIONS) contain information about how to use control methods and events in general - they don't talk about the specific set of methods and events for each standard control. I want a quick reference book that does the following for each standard control (e.g. ListBox, DataGridView, etc.): A) Lists all of the methods available for that control, what each one does, and what the parameters consist of; B) Lists all of the events for that control in firing order, indicates what causes each event to fire, and what the eventargs consist of.

    I know how to use the IDE to find the methods and events, but this doesn't tell me any of this information about them. For example, reading the list of events doesn't tell me what causes each one to fire or what order they fire in. Getting a pick list of all of the methods for a control doesn't tell me what any of them do or what differentiates similarly named methods. That's why I need a reference book.

    I am using VS 2010 .NET/C# 4.0, so if a book is available for that version it would be great. I suspect, however, that a book for an earlier version would work just as well. If you have such a book on your desk with well-worn pages then I want to know about it.

    Thanks in advance for your help!


    Craigory

    Thursday, September 5, 2013 5:43 PM

Answers

  • A single event can be raised for various reasons (i.e. adding an item to a list).  Therefore listing events in some sort of order doesn't really make sense to me.  In general the order of events shouldn't matter anyway.  For a few series of events there is a defined order and that is documented in MSDN (i.e. the ASP.NET page events). 

    But for Winforms controls you generally only have before and after events and the name of the event makes it clear.  Even for events that you consider to have some order there isn't really any guarantee.  A good example might be the events that occur when you load a form.  You might assume that you'll get the load event and the visible event and perhaps others but there is no guarantee.  If the form is never actually shown you won't get any event.  If the form is loaded but not displayed then you won't get the shown event.  Yet if you close the form you'll still get the unload event. 

    It is exceedingly rare in my experience that the event order is important.  In the few cases where it did matter the events were around a custom control I was writing and the order only mattered so I knew where I should put certain blocks of code.  Even in those cases the documentation made it clear what events represented what so I knew where code went rather than relying on some ordering.  There is some documentation in MSDN on this.  For Winforms it is here.

    • Marked as answer by Craigtronic Thursday, September 5, 2013 7:49 PM
    Thursday, September 5, 2013 7:08 PM
    Moderator

All replies

  • MSDN provides all this information.  Give MSDN the name of a type and it'll show you all the members and a summary.  Click on a specific one and it'll tell you what the parameters mean, the return value, exceptions, etc.  For events it will generally tell you what causes them.  As an example refer to ListBox.  Also note that Intellisense provides the same basic information (summary) for types, members and parameters as well.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Thursday, September 5, 2013 5:46 PM
    Moderator
  • Thursday, September 5, 2013 5:46 PM
    Moderator
  • Hi Reed,

    Thanks. I was able to use your link to find a more general entry point above that to get to all of the controls and it is very very useful. However, it's not quite there. A lesser point - When you look up an event there is no explanation of the eventargs on that page - you have to figure out how to click through a couple of other pages to get to that. Just an annoyance. However, there is a serious problems with events in general. They are always listed in alphabetical order. There doesn't appear to be any way to list them in firing order for each control. Is there another place in MSDN where this information is available by control?


    Craigory

    Thursday, September 5, 2013 6:48 PM
  • Hi Michael,

    Thanks for your reply. Please see my later reply to Reed. You also might know the answer to the question I asked him.


    Craigory

    Thursday, September 5, 2013 6:49 PM
  • A single event can be raised for various reasons (i.e. adding an item to a list).  Therefore listing events in some sort of order doesn't really make sense to me.  In general the order of events shouldn't matter anyway.  For a few series of events there is a defined order and that is documented in MSDN (i.e. the ASP.NET page events). 

    But for Winforms controls you generally only have before and after events and the name of the event makes it clear.  Even for events that you consider to have some order there isn't really any guarantee.  A good example might be the events that occur when you load a form.  You might assume that you'll get the load event and the visible event and perhaps others but there is no guarantee.  If the form is never actually shown you won't get any event.  If the form is loaded but not displayed then you won't get the shown event.  Yet if you close the form you'll still get the unload event. 

    It is exceedingly rare in my experience that the event order is important.  In the few cases where it did matter the events were around a custom control I was writing and the order only mattered so I knew where I should put certain blocks of code.  Even in those cases the documentation made it clear what events represented what so I knew where code went rather than relying on some ordering.  There is some documentation in MSDN on this.  For Winforms it is here.

    • Marked as answer by Craigtronic Thursday, September 5, 2013 7:49 PM
    Thursday, September 5, 2013 7:08 PM
    Moderator
  • Thanks Michael! Everything you said was spot on and the information you referred me to was exactly what I was looking for. Especially the focus events. I had forgotten that this was my main problem area with regards to event order. Without knowing the exact order those events fire I was getting totally off-the-wall confusing results and really had no way to figure it out. You have blessed me with your goodness oh great one! In other words, thanks very much! I'm marking this one answered.

    Craigory

    Thursday, September 5, 2013 7:48 PM