Divelements
Because everything starts with the presentation layer
Products
 Wednesday, April 04, 2007, 1:08 AM   Home Products Licensing Store Support Articles 
Troubleshooting
Home / Products

Occasionally things go wrong. The issues presented here are features of .NET, Windows Forms and Visual Studio. Although they are not the fault of the products on this site (use the bug report form for that) they affect the developers using them and can be addressed.

My control(s) disappeared in the designer

Sometimes when opening the designer window for a form, not all of your controls will be initialized correctly. This is usually because Visual Studio has had a problem resolving assembly dependancies. The most important thing to remember in this situation is not to save the form. If the form opened with only partial success and is then saved, the controls will be gone forever.

Instead, close the form designer and take a look at the designer-generated code in the InitializeComponent method. If you can see the code for your controls, you're in luck. At this stage it is quite likely that building and running your application would show the controls working perfectly. This is because this issue only affects controls running in the designer.

The fix for this issue is to close and re-open Visual Studio. As long as the referenced assemblies are intact the IDE will find them and your form will open successfully in the designer.

I've got some controls hosted within yours, and they won't display images at runtime

This is a Windows Forms issue with serialization and affects some users when hosting treeviews and listviews within controls obtainable from this site. Depending on the order that your controls are serialized relative to a) other controls and b) the imagelist to which they're bound, they can fail to display their images at runtime.

The workaround for this issue is to re-assign the ImageList property of the control that is misbehaving outside the InitializeComponent method. I have found the best place to do this is right after the call to InitializeComponent in the constructor. A single line assigning the correct ImageList to the correct control will solve the problem:

this.treeView1.ImageList = this.explorerImages;

After using your controls extensively at runtime my form is unclosable

This was a bug in Windows Forms that was fixed for the 1.1 release of the framework. When dynamically adding and removing controls to/from your form, which a lot of controls do, this bug can occur. It arises when removing a control that currently contains the focus. After that, the form becomes unclosable.

The workaround is to ensure that a control does not contain the focus when it is removed. This is best achieved by hooking an event that is fired just before removal and setting the focus to another control that is guaranteed to be there, or the form itself.

Design and content Copyright © 2003 - 2006 Divelements Limited. Content may not be reproduced without permission.