Blog - Title

Visual Studio 2013 Current Status

  • The Ultimate Visual Studio Tips and Tricks Blog

    Ever Give Your Dog Mouth-To-Mouth?



    Well!  I had an interesting night.  As many of probably know by now we have four dogs at my house:  Max (Basenji), Fibi (Jack Russell Terrier), Lily aka Piggy (we think she is a Pit Bull mix), and Zorro (Blue Tick mix).  With four dogs you are always breaking up little fights between them at one time or another.  Not sure if it is just our dogs or this is a normal thing. 


    Last night my dogs were in the backyard and I heard a little skirmish start.  I did my usual yell to tell them to cut it out but this time Zorro kept making a funny noise like he was hurt.  It didn't sound good at all.  I went out side and found Max and Zorro attacking Lilly.  Normally Lilly can handle herself no problem but she didn't seem to be fighting and it looked like Zorro had her around the neck. 


    As I approached and got Zorro to hold still I discovered that he had managed to get his lower jaw stuck in Lilly's collar.  As I looked closer I found I was having a hard time getting Zorro lose so I brought them closer into the light near our porch.  That is when I realized there was a bad problem.  Zorro was really stuck and there was blood all over Lilly. 


    I called for my wife to come down and give me some help and she began looking for a flashlight to get a better idea of what we were dealing with.  Right after she left, I noticed that Lilly had a funny look and realized she was choking--things were much worse than I thought.  OMG.  I almost freaked but held it together and called for my wife to bring me a knife (screw the collar, ill buy a new one).  It was close but I managed to cut the collar off w/o cutting Zorro or Lilly.  As soon as I cut them lose, I grabbed Lilly who had turned purple and had stopped breathing.


    I didn't know you could give a dog mouth-to-mouth but my wife (freaking out) managed to say "give her mouth-to-mouth".  Now, I have to admit, giving my dog mouth-to-mouth was not appealing to me but when you are faced with a purple dog you tend to not give a crap.  I directed her to start the car so we could take Lilly to the emergency room and gave the the dog mouth-to-mouth. 


    It worked!  I never, EVER would have thought you could resuscitate a dog that way but she started breathing slowly and we rushed her  to the emergency room.  By the time we got to the emergency room, she had completely restored breathing and was just a regular dog.  So there we were in our pajamas with a perfectly healthy dog just wagging it's tail and having a good time.  About 30 minutes and 95 dollars later we were on our way home and now we are looking for a new (hopefully safer) collar for Lilly. :P

  • The Ultimate Visual Studio Tips and Tricks Blog

    LINQ and Stored Procedures


    Okay so last quarter I was asked if you can call stored procedures using Language Integrated Query (LINQ).  The answer, of course, is YES!  It would be kind of silly if we didn't include this type of functionality. :P


    NOTE:  You need the following items to do this example

    SQL Server (pretty much any version will do but this example uses 2005)

    Visual Studio 2008 (Beta 2 was used for this example)

    A little time to sling some code



    So how exactly DO you call a stored proc using LINQ?  Easy just follow these simple steps:

    1. Create a new Windows Forms Application in Visual Studio 2008, let's call it "LINQ_SP_Coolness"

    2. Next, make sure you have a connection to some data source in your Server Explorer.  You may need to add a new connection.

    3. For the purposes of this discussion I am using the Northwind Database on SQL Server.

    4. Take a look at the existing stored procedures because what you need may already be there.

    5. Aaaaaand since I'm bored watching re-runs tonight, why don't we make our own stored procedure?

    6. Just write a simple SELECT to yank out some data AND remember to save :)

    7. Just to make sure, refresh the stored procedure folder on your data source in Server Explorer to see your shiny, new stored proc listed...

    8. You might even want to test it :P

    9. To get this to a point we can manipulate it using LINQ we need to have our classes and mappings in place.  Fortunately, this is a VERY easy thing to do.  Just right-click your project, choose Project...Add New Item from the Menu Bar.  Let's add a "LINQ to SQL Classes" item with the default name of "DataClasses1.dbml".

    10. Click and drag the stored procedure from Server Explorer on to the LINQ design surface.

    11. You should see the procedure showing up on the upper right of the design surface.

    12. Now let's slap some controls on our Windows Form.  How about a list box and a button?  Live on the edge!

    13. Now we need to work with database by establishing a context to it.  Next, we need to create a query expression that treats the result of the stored procedure as a table and query against it selecting only the LastName column.  Just for fun why don't we sort all the last names as well?  Finally, we will take the list of names returned and loop through them adding each one to our listBox as we go along.

      Double-click on the button to code for the Click event and write the following lines of code:
      (NOTE: make sure to substitute your server name in place of "zero_cool" and if you are using SQL Express you need to modify the server piece to read like this "SQLEXPRESS\myserver")

    14. If all goes well, you should get the following result:

    15. And that's how you use a stored procedure with LINQ.  This was a very simple example but if you really want to see a great series on LINQ go to my buddy Benko's site.   He has a webcast series on LINQ that kicks major butt! :)

      [Updated:  added tags]
  • The Ultimate Visual Studio Tips and Tricks Blog

    Track Active Item in Solution Explorer


    Menu:  Tools -> Options -> Projects and Solutions –> General
    Commands:  View.TrackActivityinSolutionExplorer
    Versions:  2005,2008, 2010
    Published:  3/29/2010
    Code:  vstipProj0011


    Note: Several people have asked if you can turn this feature on and off at will. You can if you bind the View.TrackActivityinSolutionExplorer command to a keyboard shortcut.


    By default, VS2010 will track the current file you are editing in Solution Explorer.  It looks like this:




    Notice that the current file being edited is also selected in Solution Explorer automatically.  This is a great way to keep track of where you are in the solution when you are working with a lot of files.  You can turn it off if you want.  Just go to Tools -> Options -> Projects and Solutions -> General -> "Track Active Item in Solution Explorer" and uncheck the option to turn this feature off.


  • The Ultimate Visual Studio Tips and Tricks Blog

    Setting Bookmarks


    Keyboard:  CTRL + K, CTRL + K (toggle bookmark)
    Menu:  Edit -> Bookmarks -> Toggle Bookmark
    Command:  Edit.ToggleBookmark
    Versions:  2008,2010
    Published:  7/5/2010
    Code:  vstipTool0047


    Bookmarks are a pretty cool feature that a lot of people don't seem to know about.  Essentially, Bookmarks are a way to mark locations in your code.  Unlike tokens ("TODO's"), Bookmarks are not stored with the source code.  There are numerous ways to set a Bookmark.  The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:



    When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:



    The good news is you don't have to keep the default name that is given for the Bookmark.  Just RIGHT CLICK the entry in the window and choose "Rename":



    Then put in whatever you want for the name and you are good to go:



    You can continue to use this method or the menu to create Bookmarks.  Another cool way to create Bookmarks is to use the "Bookmark All" (bottom right) button in the Quick Find dialog (CTRL + F):


  • The Ultimate Visual Studio Tips and Tricks Blog

    The RTM of Visual Studio 2008 Is Coming


    [EDIT:  As Guy pointed out on his blog VS2008 is RTM for MSDN already]


    By now it is no secret that Visual Studio 2008 will RTM before the end of November.  Soma mentioned this at TechEd Europe and I couldn't be more excited!  Make sure you are getting ready with for the new version by checking out our webcasts and other training materials that are available.  Here is a list of places to help you get prepared:


    Main Visual Studio 2008 Product Page


    Main World Wide Events Website

    NOTE:  Don't let the name throw you off, this is your best "one stop shop" for getting MS content.  Make sure to take advantage of the Virtual Labs!  Below is an extremely short list  at what I found when I searched on the keyword "linq":




    Channel 9 (of course)



    And of course the various blogs (on the left hand side) and other resources that crop up.   I will be doing a 26 part webcast on new features of VS2008 beginning in December as well.



    In the meantime, let's have a contest.   Post here with your list of resources for getting up to speed with VS2008.  I will randomly choose one person to be the recipient of ONE of these prizes (winner's choice):


    Windows Vista Ultimate

    Office 2007 Ultimate

    Halo 3/Flight Simulator X  Combo gift

    [Edit:  contest extended until 12/1 by popular demand!]

    Just in time for the holidays!  Contest ends on 11/26/2007 @ 5pm Central.  Good Times :)


    (MS employees not eligible but shoot me an email if you would like to see an FTE version of this contest)


  • The Ultimate Visual Studio Tips and Tricks Blog

    Collapsing Your Code with Outlining


    Keyboard:  CTRL + M, CTRL + M
    Menu:  Edit -> Outlining -> Toggle Outlining Expansion
    Command:  Edit.ToggleOutliningExpansion
    Versions:  2008,2010
    Published:  3/15/2010
    Code:  vstipEdit0029


    By default, Outlining is enabled in Visual Studio.  It's the line you see with the boxes to indicate the status of the area (collapsed or expanded):



    You can collapse areas of code to get them out of your way so you can focus on other areas.  There are four ways to do it:

    1. Click on the minus sign to collapse an area of code:


      NOTE:  In VS2010 it now highlights the area that will be collapsed as seen here.  A very cool feature.  If you don't like the highlighting color you can go to Tools -> Options -> Environment -> Fonts and Colors -> Collapsible Region to change it.

    2. VS2010 ONLY:  Click ANYWHERE on the vertical line in the highlighted region.  In other words, you can now collapse a region from anywhere in that region:
    3. Click anywhere in the area to be collapsed and hit CTRL + M, CTRL + M
    4. Click anywhere in the area to be collapsed and go to Edit -> Outlining -> Toggle Outlining Expansion on the Menu Bar


    Once collapsed, the code area will look like this:


  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2013: Zooming In and Out of Text in the Editor


    This week I thought we would focus on some fun quickies that have been in Visual Studio since at least VS2010. The first one we will look at is simply zooming your text in the editor. The concept is really simple. For example, you may want to go from this:

    5-16-2012 12-06-52 PM


    To this:

    5-16-2012 12-08-13 PM


    Being able to zoom in and out is useful if you have trouble seeing or you are doing extreme programming or any situation where making text more readable is necessary. One other thing to keep in mind is that zooming is a per tab activity so zooming in one tab does not set the same zoom level in other tabs. Each tab has it's own zoom level.



    Mouse Wheel

    You can zoom in and out of text using the wheel on your mouse. Just hold down CTRL+Mouse Wheel and you can instantly zoom in and out of text in the editor.


    Most people discover this accidentally. If this annoys you then you can see if there is an update to the Disable Mouse Wheel Zoom extension:


    At the time of writing there isn’t a version that works with VS2013 but that could change.



    Combo Box

    You can go “old school” and use the combo box at the bottom left of the IDE:

    5-16-2012 12-16-30 PM




    If you prefer to use the keyboard, you can always use CTRL+SHIFT+>[Greater Than] and CTRL+SHIFT+<[Less Than].

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2013: Format the Current Document or Selection



    NOTE: This is an older feature. I’ve updated the information for VS2013.



    Format Document

    This one is a little known feature you can take advantage of when working with your code. Assuming you have some unformatted code:

    5-16-2012 12-14-43 PM


    5-16-2012 12-10-39 PM



    You can format the entire document by going to Edit -> Advanced -> Format Document (CTRL+K, CTRL+D) to get this:

    5-16-2012 12-16-13 PM


    5-16-2012 12-18-01 PM




    Format Selection

    You can also do this with just a selection of code:

    5-16-2012 12-21-01 PM


    Go to Edit -> Advanced -> Format Selection (CTRL+K, CTRL+F) to get this:

    5-16-2012 12-23-33 PM




    Formatting Options

    I won’t go deep into it here but it’s important to remember that the automated formatting follows the default rules you can easily change by going to Tools | Options | Text Editor | [Language] | Formatting in most cases. For example, to change the HTML rules go to Tools | Options | Text Editor | HTML | Formatting:

    5-16-2012 12-27-47 PM


    In the case of HTML, you can go pretty deep into the formatting options by clicking on the Tag Specific Options button:

    5-16-2012 12-29-32 PM





    Formatting the document or selection is a great way to make your code more readable. Enjoy!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Using Solution Folders


    Menu:  Project -> Add New Solution Folder; [Right-Click Solution] -> Add -> New Solution Folder
    Command:  Project.AddNewSolutionFolder
    Versions:  2008,2010
    Published:  3/27/2010
    Code:  vstipProj0009


    Did you know there are special folders to help you organize large solutions?  There is!  They are called, appropriately enough, Solution Folders.  To create one just Right-Click on your solution (or go to Project -> Add New Solution Folder) and you will see this in Solution Explorer:



    Simply give the folder a name and you are good to go.  But so what?  I mean, what can you actually DO with these things?  Here is a list of stuff you can do:

    • Move or add projects to them. Solution Folders can be nested to create greater organizational structure.

    • Add, delete, or rename Solution Folders at any time, if the organizational requirements of the solution change.

    • Unload all projects in a Solution Folder to make them temporarily unavailable for building.

    • Collapse or hide entire Solution Folders so that you can work more easily in Solution Explorer. Hidden projects are built when you build the solution. 

    • Build or rebuild all the projects. The projects are built in the order specified by the project dependencies.


    Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created.  Microsoft recommends that you organize your projects on disk in the same way that you organize them in the solution.  But that is your call :)

  • The Ultimate Visual Studio Tips and Tricks Blog

    Gimme Some Link Luv


    Shoot me the URL to your blog and point out where you have linked to me.  I will pick one lucky to reward with a Visual Studio 2008 Backpack or 3 Visual Studio T-Shirts.

    Contest ends a week from Saturday.
Page 3 of 135 (1,345 items) 12345»