Author Archives: CooLMinE

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:

How to disable FlashPlayerPlugin process

With the release of Flash player 11.3 Adobe has changed their player so it uses a different process when playing flash videos in the browser. The main reason for that was to ensure that if for whatever reason the flash player encounters a problem the browser will be unaffected. In some cases users expressed that the new process was causing issues for them which means that the ideal thing to do in that case is to disable flash’s protected mode.

In order to disable flash’s protected mode follow the next steps:

  1. Navigate to C:\Windows\SysWOW64\Macromed\Flash (Windows 64-bit systems) or C:\Windows\System32\Macromed (Windows 32-bit systems) depending on what Windows bit version you are running
  2. Locate and open the file with the name mms.cfg
  3. Then simply change the line ProtectedMode line from ProtectedMode=1 to ProtectedMode=0
  4. Restart your browser

Now flash player should no longer start a separate process everytime a flash video is being played in your browser.