Monthly Archives: June 2013

Visual Studio 2012 Update 3

Microsoft released Visual Studio 2012 Update 3 (Visual Studio 2012.3) on June 26, 2013. This update introduces TFS build improvements as well as various bug fixes.

You can download the update from Microsoft’s download centre using the links below. Alternative you can use the links bellow to download the installation file that better suits your needs.

Note: Visual Studio 2012 Update 4 is now available. You can download it for free using the download links below.

Download Links

Web installation file: http://go.microsoft.com/?linkid=9821199
Offline installation file: http://go.microsoft.com/?linkid=9833082

How to draw Listbox items with alternative background colors

Some people find it easier to read large amount of data when the rows have an alternative background color instead of always the same. This is called Zebra Striping.

For this example we will look into implementing this technique for our ListBox control so it will look similar to this:
Listbox zebra striping

First we need to ensure that the ListBox.DrawMode property is set to DrawMode.OwnerDrawFixed. This can be accomplished by either changing the property in the properties window or by placing listBox1.DrawMode = DrawMode.OwnerDrawFixed; in your form’s constructor or any of the load events.

Then we need to handle the ListBox’s DrawItem event so we can change the colors as we like.

And we are done ! Feel free to modify the example to suit your needs.

How to allow only one application instance

The following code will ensure that your application can only have one instance active. If the user tries to open the application again while the application is already running then the application will simply quit (in this case after showing a message).

For this to work we will need to modify the Program.cs to check with the use of Mutex if the application is already running or not before we open the main form. Our check will take place in the Main method.

Your code in Program.cs should look like this:

Feel free to modify the example to suit your needs.

Get value between two strings

You might find this snippet particular useful in cases where you want to get a value between two other values.

This takes advantage of the string’s Split overload to pass an array of two values. This will result in the string being split twice, once for the first value in the array and once more for the second value. The result will be that the second value in the array that Split returns is the actual value between the first and the second value we passed as argument.

Code:

Example: