Hi, I'm Ray

I'm a software developer, full-time nerd and occasional human (while heavily caffeinated).

Articles + Posts (Year: 2019)

  • 27 May, 2019
  • C#: Building a TNoteBook component for Windows Forms as an user control (PanelBook)
  • Last week I was developing a Windows Forms (WinForms) application that required a particular kind of user interface. The application was a step-by-step wizard that had navigation buttons: "back" and "next". Think multiple steps of a setup installer. Each page occupied the same position and contains other controls. I wanted a more elegant solution other than hiding/showing and moving panels around the form.
  • 25 May, 2019
  • C#: A practical example of polymorphism for everyday projects
  • Every programming textbook and wiki is going to have a definition for polymorphism, so you don't need me to explain the concept. In my mind, polymorphism is the OOP technique of defining one interface that allows different entities to do the work. In this post I'm going to provide a practical example of subtype polymorphism or subtyping.
  • 04 Apr, 2019
  • C#: Storing settings in a SQLite database for a Windows Forms application
  • I find it's a pretty common requirement to store settings for an application, such as: "recently opened files", "last opened path" or other user preferences. I've seen this done using INI configuration files, XML and JSON text files. A few years ago I heard about SQLite; how the likes of Google Chrome were using it for storing configurations. So, I built my own helper to handle reading and writing of settings.
  • 16 Mar, 2019
  • C#: Quick and easy multi-threading on Windows Forms App with BackgroundWorker
  • Today let's talk about a common problem, you have code running and the application becomes unresponsive. If you're running something that's outputting to a textbox or using a control, the application takes considerably more time to run and locks up the form. How are you supposed to use the progress bar if the form just turns grey all the time?
  • 23 Feb, 2019
  • C#: Serialise object to XML (three flavours)
  • I feel like at some point in every project you find yourself needing to serialise an object. My immediate go-to is JSON: whether it's being send to another system or saved to disk, the magicians at Newtonsoft have made it super-easy with JSON. However, when I had a requirement to use XML, the results looked somewhat messier than I expected. Here's what I discovered when serialising an object to XML, in three flavours.

Copyright © 2014-2019 Ray Lam. All Rights Reserved.