Category Archives: Tips

Keep controls centered on resizable form

When dealing with resizable forms, managing layout can be achieved via the Anchor and Dock properties or using a layout panel. However, sometimes the design requires that certain controls stay centered, regardless of the parent form’s size. Luckily, a simple solution exists that does not involve writing centering code and handling resizing events. Read the rest of this entry


Uniform resizing of multiple containers in Windows Forms

When dealing with resizable dialogs, anchoring is the best way to ensure that certain controls, like containers or data grids, stretch and resize along with with the form itself. This ensures that the user experience is enhanced when dealing with large quantities of data that are, by default designed, viewed on small window. While this design is sufficient for certain cases, in other, more business like, there are limitations that can be overcome by using different container. Read the rest of this entry

Google data API and OAuth: “invalid_grant” error

This extremely frustrating error can be remedied by simply re-requesting device code. You will need to authorize your app again, but at least it will work. You can also try changing the secret first, but in my case it did not work.

Windows Phone Game Development Tips

Creating a new Windows Phone Game (4.0) project in Visual Studio creates bare minimum of what a game should be. However, two things remain to be set in order to make it look and feel like a proper game. Read the rest of this entry

Useful EventArgs utility class

Although there is a generic version for EventHandler delegate available in .NET Framework: EventHandler<TEventArgs>, it requires that generic argument derives from EventArgs. For very simplistic scenarios where you want to send simple data such as string or a number, creating a new class for the event argument is little too much work. Read the rest of this entry

Windows Forms AutoSize usage (.NET bug included)

Although development of Windows Forms stopped two .NET versions ago and was pretty much replaced by WPF, there are still legacy .NET applications around based on Windows Forms. Since mixing WPF and Forms is generally a bad idea, this small article aims to show that dynamic and flexible layouts are still possible and in fact easily achieved in Windows Forms. I will also show you that there are certain hoops that need to be jumped over like .NET bugs.
Read the rest of this entry

Application.DoEvents are evil

It is no small wonder that the MSDN reference page for the Application.DoEvents method comes with a (somewhat dire) warning:
Read the rest of this entry