Posts

Showing posts from August, 2014

Setting the Windows 8.1 or Server 2012 titlebar color using the registry

Image
I've recently had a problem whereby I needed to set the title bar colour in Windows 8.1 (or Windows Server 2012) to a specific colour so that I could take screenshots for our technical documentation. To ensure consistency we wanted to keep the titlebars the same colour in all our documentation. The problem here is I can get the RGB of the colour I need however you're not allowed to key a colour in using the new interface. Instead you're are left working some kind of colour wizardry moving the sliders around for several minutes. After a small amount of messing around I found the following registry keys in combination allow you to enter the RGB in hex format after the mystical d9  (not sure what this symbolises). [HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM] "ColorizationColor"=dword:d9 6badf6 "ColorizationColorBalance"=dword:00000064 "ColorizationAfterglow"=dword:d9000000 "ColorizationAfterglowBalance"=dword:00000...

Writing Chinese or other extended characters to CSV using C#.NET is garbled when viewed in Microsoft Excel

Image
We've recently had a problem when writing Chinese or other extended characters to CSV using C#.NET is garbled when viewed in Microsoft Excel. Firstly as you would expect if you use the standard ASCII encoding when using File.WriteAllText() method the Chinese characters are substituted for ???? You can work around this by overloading with the encoding parameter and using UTF8 encoding. File.WriteAllText(Filename, "Some,Sample,这是一些示例文本 这是一些示例文本 这是一些示例文本, Data", Encoding.UTF8); NOTE: if you use Unicode encoding the following may happen where Excel does not recognize the commas as delimiters. If you're trying to write the CSV data to binary you will have another problem whereby the Chinese characters are garbled. To resolve this issue you should use the GetPreamble() method to write the encoding to the start of the file. The file will now open correctly in Excel using the following sample code. private void WriteCSV() {     byte[] CSVBinaryDa...

ASP.NET checkbox and radio button vertical text alignment problems

Image
Within ASP.NET you might find when you add a control to the page that the text does not line up correctly with the checkbox or radio button with the text "falling off" the bottom of the checkbox. This looks rather awkward. I've seen several fixes that involve wrapping the checkbox in a DIV which seems over the top and you'll end up with stray DIVs defined all over your ASP.NET project. Instead create a new class AlignedControl  .AlignedControl Label  {      position: relative;      top: -2px;  } Assign the CSS class using the CssClass property. This will cause the checkbox and it's corresponding label to be wrapped in a SPAN which allows everything to work correctly <asp:CheckBox ID="chkKeepInformed" CssClass="AlignedControl" runat="server" Text="Keep me informed of future events" /> This is the difference with and without the fix. The same applies to radio buttons. Want to document your SQL se...