Magnus Lindhe

Emway website is coming soon

Today I finally released a coming soon website for my company Emway AB. Hopefully I will finish the copywriting for the official website as soon as possible. Luckily I get some help from my good friend Dan Andersson.

Emway AB

Read more

Styling a ToggleButton inside a Toolbar

If you create a default style for the ToggleButton control and expect your controls to pick it up when they are placed in a Toolbar control, you are dead wrong.

Read more

How to remove the cell focus border on Telerik's RadGridView

When it comes to removing the focus border on a grid cell of the RadGridView control the current help is a bit outdated on the subject or does not cover different themes . This short post describes how to remove the cell focus border for the Visual Studio 2013 theme. It could work for other themes as well but I have not tried.

Read more

How to turn off selection on a ListView control

In .NET Framework 4.5 the ListView control has a property called SelectionMode that determines the selection of list view items. There are three modes of operation:

  • Single - The user can select only one item at a time.
  • Multiple - The user can select multiple items without holding down a modifier key.
  • Extended - The user can select multiple consecutive items while holding down the SHIFT key.

There is however no selection mode None that disallows selection. Luckily there is another way to achieve the same behvaiour using a custom style for the ListViewItem.

The following style makes it impossible for the ListViewItem to gain focus and become selected.

    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="Focusable" Value="False"/>

This solution also works for the ListBox since ListView is a dervived control.

Read more

How to determine the version and edition of a SQL Server instance?

A colleague recently asked me how to determine the version and edition of an SQL Server instance. Microsoft has a good knowledge base article explaining it. There are the two ways I prefer of getting the version and edtion:

If you only need to do a quick check to find out the information I would just run the following query:

SELECT @@version

Which would produce something similar to this:

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)   Mar 29 2009 
10:11:52   Copyright (c) 1988-2008 Microsoft Corporation  Express 
Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: )

Or you might need the information in a more structured way. Then you could run the following query:

SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

Read more

Using ReactiveUI to bind to controls that do not support data binding

I am using ReactiveUI in Windows Forms project and want to bind a view model property to a tool strip menu item checked property. The ToolStripMenuItem control is not bindable and there is no built in support for this control in ReactiveUI.

Read more

ListBox with grid layout in WPF

I have not used WPF much and I felt that I needed to hone my skills. I wanted to layout several list items in a grid. This is what I came up with.

Read more

How to protect passwords

Yesterday I attended nForum together with some colleagues from AcobiaFLUX. Adam Lith from Squeed made an interesting presentation about how to protect passwords. Read my summary in Swedish about the advice we got from Adam.

Read more

Using Powershell to monitor disk drive failures from CitectSCADA

Today a colleague of mine asked for help with creating a Powershell script for monitoring disk failures from CitectSCADA. He wanted to use the event log to look for specific events related to disk failures. We figured that it would be best if the script was run by Windows Task Scheduler and output a file with current status of disk drives. This way we can run some Cicode periodically to check the status without having to block CitectSCADA while searching the event log.

Read more

Parsing whitespace and new lines with Sprache

Sprache is a nice and small library for creating language parsers. In Sprache you can use the Token method to get a parser for a token that disregards any whitespace that might surround the token. This is a really helpful method for any language that allows for whitespace throughout the grammar.

Read more