VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[PRB] Deleting a Toolbar, ListView, or StatusBar control prevents the form from loading in Visual Studio designer

A few VB6 controls – namely, the Toolbar, the ListView, and the StatusBar controls - are rendered in VB.NET as a pair of controls on the migrated form: one control of the pair is defined in the control support library, the other is defined in System.Windows.Forms.dll.

For example, a VB6 Toolbar control named MyToolbar is rendered as a VB6Toolbar control named MyToolbar plus a System.Windows.Forms.Toolstrip control named MyToolbar_Control.
The MyToolbar control is actually a class that derives from System.Windows.Forms.Control, is just 1x1 pixels wide, and is invisible at runtime.

This arrangement is necessary to preserve the full code-level compatibility and, at the same time, to let developers modify properties in the designer. VB.NET code referencing the MyToolbar control actually references the MyToolbar VB6Toolbar, which in turn forwards all requests to the MyToolbar_Control. The developer can directly change toolbar appearance and behavior by setting the properties of the MyToolbar_Control object.

This mechanism works well, but causes problems if the developer deletes the toolbar – that is, the MyToolbar_Control – from the designer without also deleting the MyToolbar control. In such a case, a NullReference exception is thrown at design time, which prevents the form from being displayed in the designer.

The fix for this issue is simple: If you delete a Toolbar, ListView, or StatusBar control from a form at design-time, please ensure that you also delete the corresponding VB6*** control. This control is just 1x1 pixels wide, thus the easiest way to find and select it is using the dropdown list in the property grid window.

A similar problem can occur if you move a Toolbar, ListView, or StatusBar control into another container. In this case, you should ensure that the companion control is moved into the same container.

Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers