Archive for June, 2006
In .Net Windows Forms, any form or control that derives from a Component has a DesignMode property that tells you whether the control is being rendered in design mode in Visual Studio. This is useful if your control has different behaviour at runtime than at design time (for example, if you show a connection dialog when a form opens but you don't want it to happen in design mode inside Visual Studio).
The DesignMode property has its quirks though. Using Lutz Roeder's Reflector reveals the implementation of the DesignMode property:
This shows that design time support is not hooked up until the control is sited. Siting happens after the control is created, but before any properties are set, so if you check the DesignMode property in the constructor of a control, it will always be false.
There is also a bug with the DesignMode property whereby a custom control inside a custom control will always report its DesignMode property as false. Microsoft has more details of this in knowledge base article KB839202 and in their Visual Studio feedback website..
A workaround to both of the above problems it to use the following:
A bit crude, but it works.
June 30th, 2006
The latest trend for even the simplest of tools is to provide the executables as an MSI file, requiring an installation to run the application. Lots of applications simply do not require an installation and will work if the .exe contained in the MSI file is run.
Scott Willeke has made a nice little tool called Less MSIÃ©rables (aka lessmsi) that can extract the contents of an MSI file directly to disk with no installation. Extracting the contents and running the .exe has worked successfully on every simple application I've tried so far.
June 29th, 2006
SQL Server's Enterprise Manager provides a simple results view to show the data contained in a table. With this view, it's possible to edit the data in the table but there is no obvious method of setting a nullable field to null - emptying the cell simply sets the value to empty, which may or may not work depending on the type of the column.
To set a null value, you have to use the Ctrl-0 (Control + Zero) shortcut. Why is there no option in the GUI to do this?
June 29th, 2006