How can I migrate property pages? Well that is a common question when migrating VB6 Activex controls.
Property Pages where commonly used in VB6 to provide a mechanism for your user controls to edit values.
.NET provides even more mechanisms for editing your control properties. You can provide an editor for each one of your component properties or you can provide a ComponentEditor for all the component. This editor can be actived in the designer selecting Properties from the context menu when you right click over the control.
“A component editor is used to edit a component as a whole and can be used to implement a user interface similar to that of the property pages. You associate a component editor with a component by using the EditorAttribute attribute.” From: ComponentEditor Class
The following tool will modify your project to make your PropertyPages look like UserControls. This will allow the VBUC migration tool to recover some of the PropertyPages code and appearance and with some manual changes you can get your property pages to work again.
DOWNLOAD TOOL
For each of your migrated controls that used property pages, you will need to create a ComponentEditor. The following code shows a ComponentEditor with using one property
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Collections
Imports System.Drawing
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
' This example demonstrates how to implement a component editor that hosts
' component pages and associate it with a component.
Public Class YourComponentEditor
Inherits System.Windows.Forms.Design.WindowsFormsComponentEditor
' This method override returns an type array containing the type of
' each component editor page to display.
Protected Overrides Function GetComponentEditorPages() As Type()
Return New Type() {GetType(YourComponentEditorPages)}
End Function
' This method override returns the index of the page to display when the
' component editor is first displayed.
Protected Overrides Function GetInitialComponentEditorPageIndex() As Integer
Return 0
End Function
Public Overloads Overrides Function EditComponent(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal component As Object) As Boolean
'You should add some code HERE
End Function
End Class
Friend Class YourComponentEditorPages
Inherits System.Windows.Forms.Design.ComponentEditorPage
Public Sub New()
' Initialize the page, and its controls.
'For each page do somethin like this
Dim page1 As New YourPropertyPage1
Me.Size = New Size(400, 250)
Me.Text = "Your Page Caption"
Me.Controls.Add(page1)
End Sub
' The LoadComponent method is raised when the ComponentEditorPage is displayed.
Protected Overrides Sub LoadComponent()
End Sub
' The SaveComponent method is raised when the WindowsFormsComponentEditor is closing
' or the current ComponentEditorPage is closing.
Protected Overrides Sub SaveComponent()
End Sub
End Class
After creating ComponentEditor you must associate the component Editor to your new component editors. This can be done with something like:
<EditorAttribute(GetType(YourComponent), GetType(ComponentEditor))> _
Partial Public Class CenteredLabel
Inherits System.Windows.Forms.UserControl
I hope this helps to get your code faster in .NET