Link to home
Create AccountLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

vb.net compile error: Operator '=' is not defined for types 'System.Type' and 'System.Type'

Hi Experts:

I am using VB 2010 Ultimate.

I have 2 modules that compiled when I was targetting .NET Framework 4.0 Client Profile, but when I target .NET Framework 3.5 Client Profile I get these compile errors.

Error      1      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\MyPropertyGrid.vb      114      21      Demo
Error      2      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\MyPropertyGrid.vb      121      21      Demo
Error      3      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\MyPropertyGrid.vb      139      21      Demo
Error      4      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\PointFConverter.vb      14      17      Demo
Error      5      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\PointFConverter.vb      48      17      Demo
Error      6      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\PointFConverter.vb      59      21      Demo
Error      7      Operator '=' is not defined for types 'System.Type' and 'System.Type'.      D:\Dev-Ver6.0\VB.NET\working copy root\Smart PropertyGrid.Net\Samples - vb\Demo -  .NET Framework 3.5 Client Profile\Demo\PointFConverter.vb      73      21      Demo

Here is MyPropertyGrid.vb:
Imports System
Imports System.Windows.Forms
Imports VisualHint.SmartPropertyGrid
Imports System.ComponentModel
Imports System.Drawing
Imports System.Security.Permissions
Imports System.Resources
Imports System.Reflection
Imports System.Globalization
Imports Skybound.VisualTips.Rendering

Namespace WindowsApplication

    Public Class MyPropertyGrid
        Inherits VisualHint.SmartPropertyGrid.PropertyGrid

        Public Class PlanetConverter
            Inherits TypeConverter

            Public Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
                Return True
            End Function

            Public Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As TypeConverter.StandardValuesCollection
                Return New StandardValuesCollection(New Object() {New Planet(1), New Planet(2), New Planet(3), New Planet(4), New Planet(5), New Planet(6)})
            End Function
        End Class

        <TypeConverter(GetType(PlanetConverter))> _
        Public Class Planet

            Private _name As String = ""

            Private _position As Integer = -1

            Public Sub New(ByVal name As String)
                MyBase.New()
                _name = name
            End Sub

            Public Sub New(ByVal position As Integer)
                MyBase.New()
                _position = position
            End Sub

            Public Overrides Function Equals(ByVal obj As Object) As Boolean
                Return (_name.Equals(CType(obj, Planet)._name) _
                            AndAlso (_position = CType(obj, Planet)._position))
            End Function

            Public Overrides Function GetHashCode() As Integer
                Return (_name.GetHashCode Xor _position.GetHashCode)
            End Function

            Public Overrides Function ToString() As String
                Return _name
            End Function
        End Class

        Private vtp As Skybound.VisualTips.VisualTipProvider = New Skybound.VisualTips.VisualTipProvider

        Private visualTip As Skybound.VisualTips.VisualTip = New Skybound.VisualTips.VisualTip

        Private _id As Integer = 1

        Private upDownId1 As Integer = -1

        Private upDownId2 As Integer = -1

        Private upDownId3 As Integer = -1

        Private upDownId4 As Integer = -1

        Private upDownId5 As Integer = -1

        Private buttonId1 As Integer = -1

        Private buttonId2 As Integer = -1

        Private buttonId3 As Integer = -1

        Private listId1 As Integer = -1

        Private listId2 As Integer = -1

        Private listId3 As Integer = -1

        Private sliderId1 As Integer = -1

        Private sliderId2 As Integer = -1

        Private uiTypeEditorId1 As Integer = -1

        Private uiTypeEditorId2 As Integer = -1

        Private fontId1 As Integer = -1

        Private _targetInstance As TargetClass = New TargetClass()

        Private resourceManager As ResourceManager

        Public Class MyBoolConverter
            Inherits TypeConverter

            Public Overrides Function GetStandardValuesSupported(ByVal context As ITypeDescriptorContext) As Boolean
                Return True
            End Function

            Public Overrides Function GetStandardValues(ByVal context As ITypeDescriptorContext) As TypeConverter.StandardValuesCollection
                Return New StandardValuesCollection(New Object() {MyBoolClass.False_, MyBoolClass.True_})
            End Function

            Public Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As Type) As Boolean
                If (sourceType = GetType(System.String)) Then
                    Return True
                End If
                Return MyBase.CanConvertFrom(context, sourceType)
            End Function

            Public Overrides Function CanConvertTo(ByVal context As ITypeDescriptorContext, ByVal destinationType As Type) As Boolean
                If (destinationType = GetType(System.String)) Then
                    Return True
                End If
                Return MyBase.CanConvertTo(context, destinationType)
            End Function

            Public Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object) As Object
                If (TypeOf value Is String) Then
                    If value.Equals("No value") Then
                        Return MyBoolClass.False_
                    ElseIf value.Equals("Value defined") Then
                        Return MyBoolClass.True_
                    End If
                End If
                Return MyBase.ConvertFrom(context, culture, value)
            End Function

            Public Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object, ByVal destinationType As Type) As Object
                If (destinationType = GetType(String)) Then
                    If value.Equals(MyBoolClass.True_) Then
                        Return "Value defined"
                    ElseIf value.Equals(MyBoolClass.False_) Then
                        Return "No value"
                    End If
                End If
                Return MyBase.ConvertTo(context, culture, value, destinationType)
            End Function

            Public Overrides Function GetStandardValuesExclusive(ByVal context As ITypeDescriptorContext) As Boolean
                Return True
            End Function
        End Class

        <TypeConverter(GetType(MyBoolConverter))> _
        Public Class MyBoolClass

            Public Shared True_ As MyBoolClass = New MyBoolClass(True)

            Public Shared False_ As MyBoolClass = New MyBoolClass(False)

            Private _value As Boolean

            Public Sub New(ByVal value As Boolean)
                MyBase.New()
                _value = value
            End Sub

            Public Overrides Function Equals(ByVal obj As Object) As Boolean
                If (obj Is Nothing) Then
                    Return False
                End If
                If (TypeOf obj Is MyBoolClass) Then
                    Return (Me._value = CType(obj, MyBoolClass)._value)
                End If
                Return MyBase.Equals(obj)
            End Function

            Public Overrides Function GetHashCode() As Integer
                Return MyBase.GetHashCode
            End Function
        End Class

        Public Sub Populate()
            BeginUpdate()
            HideCategoriesMode = HideCategoriesModes.HideEmptyRootCategories
            ' Register event handlers
            AddHandler PropertyCreated, AddressOf Me.MyPropertyGrid_PropertyCreated
            AddHandler DisplayedValuesNeeded, AddressOf Me.MyPropertyGrid_DisplayedValuesNeeded
            AddHandler ValueValidation, AddressOf Me.MyPropertyGrid_ValueValidation
            AddHandler PropertyUpDown, AddressOf Me.MyPropertyGrid_PropertyUpDown
            AddHandler InPlaceCtrlVisible, AddressOf Me.MyPropertyGrid_InPlaceCtrlVisible
            AddHandler PropertyChanged, AddressOf Me.MyPropertyGrid_PropertyChanged
            AddHandler PropertyButtonClicked, AddressOf Me.MyPropertyGrid_PropertyButtonClicked
            Dim propEnum As PropertyEnumerator
            Dim subEnum As PropertyEnumerator
            ' All simple textboxes
            '---------------------
            Dim rootEnum As PropertyEnumerator = AppendRootCategory(_id, "Textboxes alone")
            _id += 1
            rootEnum.Property.Comment = "Icons can be set on categories and subcategories. They are supplied through an ImageList set on the g" & _
            "rid."
            rootEnum.Property.ImageIndex = 0
            propEnum = AppendProperty(rootEnum, _id, "Simple string", _targetInstance, "Editbox1", "")
            _id += 1
            propEnum.Property.Value.Font = New Font(Font, FontStyle.Italic)
            propEnum.Property.Comment = "Icons can be set on property labels. They are supplied through an ImageList set on the grid." & vbLf & vbLf & "A bold " & _
            "font has been set on the Value. A validator is also attached: it checks that the first letter is upp" & _
            "ercase."
            propEnum.Property.ImageIndex = 1
            propEnum.Property.Value.ImageSource = ImageSources.Grid
            propEnum.Property.Value.ImageIndex = 5
#If (_DOTNET2) Then
            propEnum = AppendProperty(rootEnum, _id++, "Masked textbox", _targetInstance, "Editbox11", "")
            propEnum.Property.Feel = GetRegisteredFeel(FeelMaskedEdit)
            propEnum.Property.Look = New PropertyMaskedEditLook("(000) 000-0000")
            propEnum.Property.Value.ForeColor = Color.Red
            propEnum.Property.Value.Font = New Font(Font, FontStyle.Bold)
            propEnum.Property.Comment = "The text color can be changed on the value."
#End If
            ' Multiline editbox
            propEnum = AppendProperty(rootEnum, _id, "Multiline Edit box", _targetInstance, "Editbox3", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelMultilineEdit)
            propEnum.Property.HeightMultiplier = 3
            propEnum.Property.Look = New PropertyMultilineEditLook
            propEnum.Property.Comment = "Icons can be set on values. They can be supplied through various sources. Here it comes from an Image" & _
            "List." & vbLf & vbLf & "You can choose the height of a multiline property."
            propEnum.Property.Value.ImageSource = ImageSources.Grid
            propEnum.Property.Value.ImageIndex = 3
            ' Add a simple edit box property attached to an integer
            propEnum = AppendProperty(rootEnum, _id, "Simple integer", _targetInstance, "Editbox2", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEdit)
            propEnum.Property.Comment = "A validator object has been attached to this property to set a valid range [0..200]."
            ' Password
            propEnum = AppendProperty(rootEnum, _id, "Password", _targetInstance, "Editbox10", "")
            _id += 1
            propEnum.Property.Comment = "This property uses custom look and feel classes to display a password."
            ' All buttons
            '------------
            rootEnum = AppendRootCategory(_id, "Buttons")
            _id += 1
            CType(rootEnum.Property, RootCategory).ValueText = "(13 properties)"
            rootEnum.Property.Comment = "This category has a non editable value. This is useful for example to show a key child property value" & _
            " when the category is collapsed."
            subEnum = AppendSubCategory(rootEnum, _id, "Simple buttons")
            _id += 1
            CType(subEnum.Property, RootCategory).ValueText = "(3 properties)"
            subEnum.Property.Comment = "This subcategory has a non editable value. This is useful for example to show a key child property va" & _
            "lue when the category is collapsed."
            buttonId1 = _id
            propEnum = AppendManagedProperty(subEnum, _id, "Button1", GetType(System.Int32), 100, "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditButton)
            propEnum.Property.Comment = "This button has a custom text."
            buttonId2 = _id
            propEnum = AppendProperty(subEnum, _id, "Button2", _targetInstance, "ButtonVar1", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelButton)
            propEnum.Property.Font = New Font(Font, FontStyle.Italic)
            propEnum.Property.Value.Font = New Font(Font, FontStyle.Bold)
            propEnum = AppendManagedProperty(subEnum, _id, "Font", GetType(Font), New Font("Arial", 15.0!), "", New ShowChildPropertiesAttribute(False))
            _id += 1
            ' Checkboxes
            subEnum = AppendSubCategory(rootEnum, _id, "Checkboxes")
            _id += 1
            propEnum = AppendProperty(subEnum, _id, "Enumeration", _targetInstance, "ButtonVar3", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelCheckbox)
            propEnum.Property.Look = New PropertyCheckboxLook
            propEnum.Property.Value.Font = New Font(Font, FontStyle.Bold)
            propEnum.Property.Comment = "This property is linked to an enumeration which has the [Flags] attribute."
            buttonId3 = _id
            propEnum = AppendProperty(subEnum, _id, "Boolean", _targetInstance, "ListVar3", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelCheckbox)
            propEnum.Property.Look = New PropertyCheckboxLook
            propEnum.Property.Comment = "Checkboxes can also be applied to a simple boolean and the displayed values can be customized."
#If (_DOTNET2) Then
            propEnum = AppendManagedProperty(subEnum, _id, "Nullable boolean", GetType(bool?), Nothing, "")
            _id+=1
            propEnum.Property.Feel = GetRegisteredFeel(FeelCheckbox)
            propEnum.Property.Look = New PropertyCheckboxLook
            propEnum.Property.Value.ResetDisplayedValues(true, New Object() {true, "Yes", false, "No", Nothing, "Undefined"})
#End If
            propEnum = AppendManagedProperty(subEnum, _id, "Any class (2 values)", GetType(MyBoolClass), MyBoolClass.True_, "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelCheckbox)
            propEnum.Property.Look = New PropertyCheckboxLook
            propEnum.Property.Comment = "The target property is a class whose TypeConverter publishes two values."
            ' Radio buttons
            subEnum = AppendSubCategory(rootEnum, _id, "Radio buttons")
            _id += 1
            propEnum = AppendProperty(subEnum, _id, "Radio buttons", _targetInstance, "ButtonVar4", "")
            _id += 1
            propEnum.Property.Look = New PropertyRadioButtonLook
            propEnum.Property.Feel = GetRegisteredFeel(FeelRadioButton)
            propEnum.Property.Comment = "This property is linked to an enumeration and displays custom strings."
            ' UpDown buttons
            subEnum = AppendSubCategory(rootEnum, _id, "Updown buttons")
            _id += 1
            propEnum = AppendProperty(subEnum, _id, "Time", _targetInstance, "Time", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelDateTime)
            '            propEnum.Property.Look = new PropertyDateTimeLook(DateTimePickerFormat.Time);
            propEnum.Property.Look = New PropertyDateTimeLook("mm:ss")
            upDownId1 = _id
            propEnum = AppendProperty(subEnum, _id, "Enum", _targetInstance, "UpDownVar1", "")
            _id += 1
            propEnum.Property.Value.BackColor = Color.Cornsilk
            propEnum.Property.Feel = GetRegisteredFeel(FeelUpDown)
            propEnum.Property.Comment = "An updown control is also neat with an enumeration. Realtime mode has been set to true so no cancella" & _
            "tion possible with Escape."
            upDownId2 = _id
            propEnum = AppendProperty(subEnum, _id, "Enum", _targetInstance, "UpDownVar2", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditUpDown)
            propEnum.Property.Value.Font = New Font(Font, FontStyle.Bold)
            propEnum.Property.Comment = "An updown control is also neat with an enumeratiom. Here I added a textbox."
            upDownId3 = _id
            propEnum = AppendProperty(subEnum, _id, "Boolean", _targetInstance, "UpDownVar3", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditUpDown)
            propEnum.Property.BackColor = Color.WhiteSmoke
            propEnum.Property.ForeColor = Color.CadetBlue
            propEnum.Property.Value.BackColor = GridBackColor
            propEnum.Property.Value.ForeColor = GridForeColor
            propEnum.Property.Comment = "An updown control can also be used with a boolean. Maybe not very common but it shows you how value t" & _
            "ypes and inplace controls can be associated in a flexible way."
            upDownId4 = _id
            propEnum = AppendProperty(subEnum, _id, "Custom increment", _targetInstance, "UpDownVar4", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditUpDown)
            propEnum.Property.Comment = "The content is modified dynamically via notification. Here the increment is changed to 0.05. Limits b" & _
            "etween -1.0 and 1.0."
            propEnum.Property.Value.Validator = New PropertyValidatorMinMax(propEnum, -1, 1)
            upDownId5 = _id
            propEnum = AppendProperty(subEnum, _id, "Custom list", _targetInstance, "UpDownVar5", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditUpDown)
            propEnum.Property.Comment = "The content of this property is changed at runtime. This is in fact a simple string."
            ' Lists
            '------
            rootEnum = AppendRootCategory(_id, "Lists")
            _id += 1
            listId1 = _id
            propEnum = AppendProperty(rootEnum, _id, "Enum", _targetInstance, "ListVar1", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelList)
            SetManuallyDisabled(propEnum, True)
            EnableProperty(propEnum, False)
            propEnum.Property.Comment = "Displays a simple enumeration. It has no textbox. A checkbox allows the user to disable the property." & _
            ""
            '            return;
            listId2 = _id
            propEnum = AppendProperty(rootEnum, _id, "Enum", _targetInstance, "ListVar2", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditList)
            propEnum.Property.Comment = "Compared to the previous one I added a textbox."
            propEnum = AppendProperty(rootEnum, _id, "Enum with icons", _targetInstance, "ListVar8", "By just adding an ImageList to the Value, you can nicely enhance the user experience.")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelList)
            Dim il As ImageList = New ImageList
            il.ColorDepth = ColorDepth.Depth32Bit
            il.Images.Add(CType(My.Resources.browser_firefox, Bitmap))
            il.Images.Add(CType(My.Resources.browser_internetexplorer, Bitmap))
            il.Images.Add(CType(My.Resources.browser_netscape, Bitmap))
            il.Images.Add(CType(My.Resources.browser_opera, Bitmap))
            propEnum.Property.Value.ImageList = il
            propEnum = AppendProperty(rootEnum, _id, "Boolean", _targetInstance, "ListVar3", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditList)
            propEnum.Property.Comment = "The list is linked to a boolean but the displayed strings have been customized."
            propEnum = AppendProperty(rootEnum, _id, "Alpha color", _targetInstance, "ListVar4", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelList)
            propEnum.Property.Look = New PropertyAlphaColorLook
            propEnum.Property.Comment = "Uses a custom look and feel to edit color with alpha"
            listId3 = _id
            propEnum = AppendProperty(rootEnum, _id, "List of dynamic strings", _targetInstance, "ListVar6", "", New UseFeelCacheAttribute)
            _id += 1
            propEnum.Property.Comment = "This property displays a simple string. Possible values are requested to the client app by callback."
            '            propEnum.Property.Value.UseAutoCompletion = false;
            propEnum = AppendManagedProperty(rootEnum, _id, "List of Planets / no names", GetType(Planet), New Planet(5), "", New PropertyValueDisplayedAsAttribute(True, New Object() {New Planet(1), "Mercury", New Planet(2), "Venus", New Planet(3), "Earth", New Planet(4), "Mars", New Planet(5), "Jupiter", New Planet(6), "Saturn"}))
            _id += 1
            propEnum.Property.Comment = "This property displays a Planet instance. Displayed strings are setup with a PropertyValueDisplayedAs" & _
            " attribute filled with <key,value> pairs where the key is a planet and the value its string represen" & _
            "tation."
            propEnum = AppendManagedProperty(rootEnum, _id, "List of Planets", GetType(Planet), New Planet("Venus"), "", New PropertyValueDisplayedAsAttribute(False, New Object() {New Planet("Mercury"), New Planet("Venus"), New Planet("Earth"), New Planet("Mars"), New Planet("Jupiter"), New Planet("Saturn")}))
            _id += 1
            propEnum.Property.Comment = "This property displays a Planet instance. Displayed strings are setup with a PropertyValueDisplayedAs" & _
            " attribute filled with instance of named planets."
            propEnum = AppendProperty(rootEnum, _id, "Frequency", _targetInstance, "ListVar7", "")
            _id += 1
            propEnum.Property.AddValue(PropertyUnitLook.UnitValue, _targetInstance, "Unit", Nothing)
            propEnum.Property.Look = New PropertyUnitLook
            propEnum.Property.Feel = GetRegisteredFeel(FeelEditUnit)
            propEnum.Property.Comment = "This property displays 2 values in one row."
            propEnum.Property.GetValue(PropertyUnitLook.UnitValue).SetValue(TargetClass.Units.Hz)
            propEnum = AppendProperty(rootEnum, _id, "Date", _targetInstance, "Date_", "")
            _id += 1
            ' UITypeEditors
            '--------------
            rootEnum = AppendRootCategory(_id, "UITypeEditors")
            _id += 1
            rootEnum.Property.Comment = "SPG.Net is now compatible with all Microsoft and custom UITypeEditors."
            propEnum = AppendProperty(rootEnum, _id, "Font name", _targetInstance, "FontName", "")
            _id += 1
            propEnum.Property.Look = New PropertyFontNameLook
#If (_DOTNET2) Then
            propEnum = AppendProperty(rootEnum, _id++, "Long string", _targetInstance, "LongString", "")
#End If
            uiTypeEditorId1 = _id
            propEnum = AppendProperty(rootEnum, _id, "Colors", _targetInstance, "ColorArray", "")
            _id += 1
            '            propEnum = AppendManagedProperty(rootEnum, _id++, "Colors", typeof(Color[]), _targetInstance.ColorArray, "");
            ExpandProperty(propEnum, True)
            propEnum = AppendManagedProperty(rootEnum, _id, "Shortcut", GetType(Keys), Keys.A, "")
            _id += 1
            propEnum = AppendManagedProperty(rootEnum, _id, "Dock", GetType(DockStyle), DockStyle.Fill, "")
            _id += 1
            uiTypeEditorId2 = _id
            propEnum = AppendManagedProperty(rootEnum, _id, "Color", GetType(Color), Color.Red, "", New PropertyLookAttribute(GetType(PropertyColorLook)))
            _id += 1
            propEnum.Property.Comment = "Replicates the usual way to edit a color."
            propEnum = AppendManagedProperty(rootEnum, _id, "Cursor", GetType(Cursor), Cursors.Default, "")
            _id += 1
            propEnum = AppendManagedProperty(rootEnum, _id, "Alignment", GetType(ContentAlignment), ContentAlignment.BottomLeft, "")
            _id += 1
            propEnum = AppendManagedProperty(rootEnum, _id, "Icon", GetType(Icon), SystemIcons.Error, "", New ShowChildPropertiesAttribute(False))
            _id += 1
            ' Misc inplace controls and looks
            '--------------------------------
            rootEnum = AppendRootCategory(_id, "Miscellaneous")
            _id += 1
            subEnum = AppendSubCategory(rootEnum, _id, "Trackbars")
            _id += 1
            ' The same with a slider control
            sliderId1 = _id
            propEnum = AppendProperty(subEnum, _id, "Trackbar", _targetInstance, "Editbox5", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelTrackbar)
            propEnum.Property.Comment = "Result is deferred until validation. The limits have been set to [0 ..200]."
            sliderId2 = _id
            propEnum = AppendProperty(subEnum, _id, "Trackbar + textbox", _targetInstance, "Editbox5", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelTrackbarEdit)
            propEnum.Property.Comment = "Result is applied in realtime and modifies another property. The limits have been set to [0 ..200]."
            propEnum = AppendProperty(subEnum, _id, "PointF/generic trackbars", _targetInstance, "MyPoint", "")
            _id += 1
            propEnum.Property.Comment = "Trackbars are attached to the child properties. A trackbar can be associated with integer, float, dou" & _
            "ble and decimal properties."
            ExpandProperty(propEnum, True)
            subEnum = AppendSubCategory(rootEnum, _id, "Others")
            _id += 1
            propEnum = AppendProperty(subEnum, _id, "Progress bar", _targetInstance, "Editbox5", "")
            _id += 1
            propEnum.Property.Look = New PropertyProgressBarLook(True, "{0}%")
            propEnum.Property.Comment = "The value of the progress bar depends on the above sliders. The text has been customized to show a pe" & _
            "rcentage."
            ' The same but disabled
            propEnum = AppendProperty(subEnum, _id, "Disabled item", _targetInstance, "Editbox6", "")
            _id += 1
            EnableProperty(propEnum, False)
            propEnum.Property.Comment = "This property has been explicitely disabled even if the underlying C# property is not readonly."
            ' A true readonly property
            propEnum = AppendProperty(subEnum, _id, "Readonly item", _targetInstance, "Editbox12", "")
            _id += 1
            propEnum.Property.Comment = "This underlying C# property is decorated with the Readonly attribute so you can't change this state. " & _
            "The color of the text can still be changed."
            '            propEnum.Property.DisabledForeColor = Color.DarkKhaki;
            propEnum = AppendHyperLinkProperty(subEnum, _id, "Disable left grid", "")
            _id += 1
            propEnum.Property.Comment = "Do whatever you want from an hyperlink click event handler."
            ' Create the first category and add a comment
            '--------------------------------------------
            rootEnum = AppendRootCategory(_id, "Reflection and customization")
            _id += 1
            fontId1 = _id
            propEnum = AppendProperty(rootEnum, _id, "Font", _targetInstance, "MyFont", "", New PropertyHideAttribute("GdiCharSet"), New PropertyHideAttribute("GdiVerticalFont"), New PropertyHideAttribute("Unit"))
            _id += 1
            propEnum.Property.Comment = "This property content is discovered by reflection but I customized it to hide certain subproperties. " & _
            "A color has also been added and a specific feel applied to the Size property."
            propEnum.Property.Value.Validator = New PropertyValidatorFontSize(propEnum, 5.0!, 15.0!)
            propEnum = AppendProperty(rootEnum, _id, "Rectangle", _targetInstance, "Rect", "")
            _id += 1
            propEnum.Property.Feel = GetRegisteredFeel(FeelEdit)
            propEnum.Property.Comment = "This property content is discovered by reflection but I customized it to hide certain subproperties."
            propEnum = AppendProperty(rootEnum, _id, "Pen", _targetInstance, "Pen", "")
            _id += 1
            propEnum.Property.Feel = Nothing
            propEnum.Property.Comment = "This property content is discovered by reflection but I customized it to hide certain subproperties. " & _
            "The parent node is custom drawn to reflect the color, width and type of the pen. The color has custo" & _
            "m feel and look."
            ' Grouped property
            '-----------------
            rootEnum = AppendRootCategory(_id, "Independent group")
            _id += 1
            Dim grPropEnum As PropertyEnumerator = AppendManagedProperty(rootEnum, _id, "Task name", GetType(String), "Write next version", "")
            _id += 1
            Dim propEnum2 As PropertyEnumerator = AppendManagedProperty(grPropEnum, _id, "Start date", GetType(DateTime), New DateTime(2008, 1, 1), "")
            _id += 1
            '            (propEnum2.Property.Look as PropertyDateTimeLook).Format = DateTimePickerFormat.Short;
            propEnum2 = AppendManagedProperty(grPropEnum, _id, "End date", GetType(DateTime), New DateTime(2008, 3, 1), "")
            _id += 1
            '            (propEnum2.Property.Look as PropertyDateTimeLook).Format = DateTimePickerFormat.Short;
            ExpandProperty(grPropEnum, True)
            EndUpdate()
        End Sub

        Private Sub MyPropertyGrid_ValueValidation(ByVal sender As Object, ByVal e As ValueValidationEventArgs)
            If (e.ValueValidationResult = PropertyValue.ValueValidationResult.ExceptionByUITypeEditor) Then
                MessageBox.Show(If(Not (e.Exception.InnerException Is Nothing), e.Exception.InnerException.Message, e.Message), _
                    "Properties window", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                Return
            End If
            If (((e.ValueValidationResult And PropertyValue.ValueValidationResult.ErrorCode) _
                        <> 0) _
                        AndAlso (ValueNotValidBehaviorMode = ValueNotValidBehaviorModes.KeepFocus)) Then
                If Not vtp.IsTipDisplayed Then
                    Dim options As Skybound.VisualTips.VisualTipDisplayOptions = (Skybound.VisualTips.VisualTipDisplayOptions.HideOnKeyDown _
                                Or (Skybound.VisualTips.VisualTipDisplayOptions.HideOnKeyPress _
                                Or (Skybound.VisualTips.VisualTipDisplayOptions.HideOnLostFocus _
                                Or (Skybound.VisualTips.VisualTipDisplayOptions.HideOnMouseDown _
                                Or (Skybound.VisualTips.VisualTipDisplayOptions.ForwardEscapeKey Or Skybound.VisualTips.VisualTipDisplayOptions.HideOnTextChanged)))))
                    Dim tb As Control = CType(InPlaceControl, IInPlaceControl).TextBox
                    If (tb Is Nothing) Then
                        tb = CType(InPlaceControl, TextBoxBase)
                    End If
                    If (tb Is Nothing) Then
                        tb = InPlaceControl
                        options = options And (Not Skybound.VisualTips.VisualTipDisplayOptions.HideOnKeyDown) And _
                            (Not Skybound.VisualTips.VisualTipDisplayOptions.HideOnKeyPress) & _
                            (Not Skybound.VisualTips.VisualTipDisplayOptions.HideOnMouseDown) & _
                            (Not Skybound.VisualTips.VisualTipDisplayOptions.HideOnTextChanged)
                    End If
                    If (Not (tb) Is Nothing) Then
                        Dim rect As Rectangle = Rectangle.Intersect(InPlaceControl.RectangleToScreen(InPlaceControl.ClientRectangle), InternalGrid.RectangleToScreen(InternalGrid.ClientRectangle))
                        visualTip.Text = e.Message
                        visualTip.FooterText = "Need help? Press F1"
                        visualTip.Image = CType(My.Resources.warning, Bitmap)
                        visualTip.Font = New Font(visualTip.Font, FontStyle.Regular)
                        visualTip.Title = e.PropertyEnum.Property.DisplayName
                        vtp.SetVisualTip(e.PropertyEnum, visualTip)
                        vtp.ShowTip(visualTip, rect, tb, options)
                    End If
                End If
            Else
                vtp.HideTip()
            End If
        End Sub

        Private Sub MyPropertyGrid_PropertyButtonClicked(ByVal sender As Object, ByVal e As PropertyButtonClickedEventArgs)
            MessageBox.Show("OnPropertyButtonClicked")
            e.PropertyEnum.Property.Value.SetValue(99)
            e.PropertyChanged = True
        End Sub

        Private Sub MyPropertyGrid_PropertyChanged(ByVal sender As Object, ByVal e As VisualHint.SmartPropertyGrid.PropertyChangedEventArgs)
            If (e.PropertyEnum.Property.Id = uiTypeEditorId1) Then
                Dim childEnum As PropertyEnumerator = e.PropertyEnum.Children
                childEnum.MoveFirst()
                Dim i As Integer = 1

                While (childEnum <> childEnum.RightBound)
                    childEnum.Property.DisplayName = ("Color " _
                                + (i + 1))
                    childEnum.MoveNext()

                End While
            End If
        End Sub

        Private Sub MyPropertyGrid_InPlaceCtrlVisible(ByVal sender As Object, ByVal e As InPlaceCtrlVisibleEventArgs)
            If (SelectedObjects.Length > 0) Then
                Return
            End If
            If (e.PropertyEnum.Property.Id = upDownId1) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceUpDown) Then
                    CType(e.InPlaceCtrl, PropInPlaceUpDown).RealtimeChange = True
                End If
            ElseIf (e.PropertyEnum.Property.Id = upDownId2) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceUpDown) Then
                    CType(e.InPlaceCtrl, PropInPlaceUpDown).RealtimeChange = False
                End If
            ElseIf (e.PropertyEnum.Property.Id = upDownId3) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceUpDown) Then
                    CType(e.InPlaceCtrl, PropInPlaceUpDown).RealtimeChange = True
                End If
            ElseIf (e.PropertyEnum.Property.Id = upDownId4) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceUpDown) Then
                    CType(e.InPlaceCtrl, PropInPlaceUpDown).RealtimeChange = False
                End If
            ElseIf (e.PropertyEnum.Property.Id = upDownId5) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceUpDown) Then
                    CType(e.InPlaceCtrl, PropInPlaceUpDown).RealtimeChange = True
                End If
            ElseIf (e.PropertyEnum.Property.Id = sliderId2) Then
                If (TypeOf e.InPlaceCtrl Is PropInPlaceTrackbar) Then
                    CType(e.InPlaceCtrl, PropInPlaceTrackbar).RealtimeChange = True
                End If
            ElseIf (TypeOf e.InPlaceCtrl Is PropInPlaceTrackbar) Then
                CType(e.InPlaceCtrl, PropInPlaceTrackbar).RealtimeChange = False
            ElseIf (TypeOf e.InPlaceCtrl Is PropInPlaceButton) Then
                If (e.PropertyEnum.Property.Id = buttonId1) Then
                    CType(e.InPlaceCtrl, PropInPlaceButton).ButtonText = "test"
                Else
                    CType(e.InPlaceCtrl, PropInPlaceButton).ButtonText = "..."
                End If
            End If
            ' If you want instant validation while typing in a textbox, uncomment this:
            ' But beware, in this case, the options for vtp.ShowTip() must not include HideOnLostFocus,
            ' HideOnMouseDown and ForwardEscapeKey
        End Sub

        Private Sub TextBox_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
            Dim tb As Control = CType(InPlaceControl, IInPlaceControl).TextBox
            If (tb Is Nothing) Then
                tb = CType(InPlaceControl, TextBoxBase)
            End If
            If (Not (tb) Is Nothing) Then
                Dim propValue As PropertyValue = SelectedPropertyEnumerator.Property.Value
                Dim value As Object = Nothing
                vtp.HideTip()
                Try
                    value = propValue.ConvertDisplayedStringToValue(tb.Text)
                Catch ex As Exception
                    NotifyValueValidation(New ValueValidationEventArgs(SelectedPropertyEnumerator, SelectedPropertyEnumerator, value, PropertyValue.ValueValidationResult.TypeConverterFailed, ex))
                    Return
                End Try
                Dim invalidPropEnum As PropertyEnumerator = Nothing
                If Not propValue.ValidateValue(value, invalidPropEnum) Then
                    NotifyValueValidation(New ValueValidationEventArgs(SelectedPropertyEnumerator, invalidPropEnum, value, PropertyValue.ValueValidationResult.ValidatorFailed))
                End If
            End If
        End Sub

        Sub MyPropertyGrid_PropertyCreated(ByVal sender As Object, ByVal e As PropertyCreatedEventArgs)
            If ((e.PropertyEnum.Property.Id = fontId1) _
                        And (Not (_targetInstance.MyFont) Is Nothing)) Then
                Dim childEnum As PropertyEnumerator = e.PropertyEnum.Children
                If (childEnum.Count > 0) Then
                    childEnum.MoveFirst()
                    childEnum.Property.Comment = "Uses a UITypeEditor. By the way, you can set comments to auto-discovered subproperties..."
                    childEnum.MoveNext()
                    childEnum.Property.Comment = "A custom feel has been applied to this property. It is done by setting an attribute to its parent. Al" & _
                    "so a validator constrains the value between 5 and 15."
                    childEnum.Property.Value.Validator = New PropertyValidatorMinMax(childEnum, CType(5, Single), CType(15, Single))
                    childEnum.MoveNext()
                    Dim propEnum As PropertyEnumerator = InsertProperty(childEnum, 150, "Color", _targetInstance, "FontColor", "")
                    propEnum.Property.Feel = GetRegisteredFeel(FeelList)
                    propEnum.Property.Look = New PropertyAlphaColorLook
                    propEnum.Property.Comment = "This color has been added to the children of the font. It uses an alpha color editor."
                    propEnum.MoveNext()
                    propEnum.Property.Comment = "The text of a checkbox can be removed."
                    propEnum.MoveNext()
                    propEnum.Property.Comment = "The text of a checkbox can be customized."
                End If
            ElseIf (e.PropertyEnum.Property.Id = uiTypeEditorId1) Then
                Dim childEnum As PropertyEnumerator = e.PropertyEnum.Children
                childEnum.MoveFirst()
                Dim i As Integer = 1

                While (childEnum <> childEnum.RightBound)
                    childEnum.Property.DisplayName = ("Color " _
                                + (i + 1))
                    childEnum.MoveNext()

                End While
            End If
        End Sub

        Private Sub MyPropertyGrid_DisplayedValuesNeeded(ByVal sender As Object, ByVal e As DisplayedValuesNeededEventArgs)
            If (e.PropertyEnum.Property.Id = listId3) Then
                e.DisplayedValues = New String() {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn"}
            ElseIf (e.PropertyEnum.Property.Id = buttonId3) Then
                e.DisplayedValues = New String() {"Enabled", "Disabled"}
            End If
        End Sub

        Private Sub MyPropertyGrid_PropertyUpDown(ByVal sender As Object, ByVal e As PropertyUpDownEventArgs)
            If (e.PropertyEnum.Property.Id = upDownId4) Then
                Try
                    e.Value = (Double.Parse(e.Value) _
                                + (e.ButtonPressed = PropertyUpDownEventArgs.UpDownButtons.Up))
                    'TODO: Warning!!!, inline IF is not supported ?
                Catch FE As FormatException

                End Try
            ElseIf (e.PropertyEnum.Property.Id = upDownId5) Then
                Dim index As Integer = _targetInstance.upDownString.IndexOf(e.Value)
                Try
                    e.Value = CType(_targetInstance.upDownString((index _
                                + (e.ButtonPressed = PropertyUpDownEventArgs.UpDownButtons.Up))), String)
                    'TODO: Warning!!!, inline IF is not supported ?
                Catch AOORE As ArgumentOutOfRangeException

                End Try
            End If
        End Sub

        Public Sub New()
            MyBase.New()
            ReadOnlyVisual = ReadOnlyVisuals.ReadOnlyFeel
            'resourceManager = New ResourceManager("WindowsApplication.MainResources", Assembly.GetExecutingAssembly)
            ImageList = New ImageList
            '            ImageList.TransparentColor = Color.FromArgb(255, 0, 255);
            '          ImageList.ImageSize = new Size(16,15);
            '        ImageList.Images.AddStrip((Bitmap)resourceManager.GetObject("icons"));
            ImageList.ColorDepth = ColorDepth.Depth32Bit
            ImageList.Images.Add(CType(My.Resources._1_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._2_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._3_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._4_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._5_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._6_16, Bitmap))
            ImageList.Images.Add(CType(My.Resources._7_16, Bitmap))
            DefaultFeel = GetRegisteredFeel(FeelEdit)
            DrawingManager = DrawManagers.DotnetDrawManager
            Dim renderer As Skybound.VisualTips.Rendering.VisualTipOfficeRenderer = New Skybound.VisualTips.Rendering.VisualTipOfficeRenderer
            renderer.Preset = VisualTipOfficePreset.Hazel
            renderer.BackgroundEffect = Skybound.VisualTips.Rendering.VisualTipOfficeBackgroundEffect.Gradient
            vtp.Renderer = renderer
            vtp.DisplayMode = Skybound.VisualTips.VisualTipDisplayMode.Manual
            vtp.Opacity = 1
        End Sub

        <SecurityPermission(SecurityAction.LinkDemand, Flags:=SecurityPermissionFlag.UnmanagedCode)> _
        Protected Overrides Function ProcessKeyPreview(ByRef m As Message) As Boolean
            If ((m.Msg = Win32Calls.WM_KEYDOWN) _
                        AndAlso (m.HWnd = InternalGrid.Handle)) Then
                If (CType(CType(m.WParam, Integer), Keys) = Keys.Delete) Then
                    '                    DeleteProperty(SelectedPropertyEnumerator);
                    '                  return true;
                End If
            End If
            Return MyBase.ProcessKeyPreview(m)
        End Function

        Private propertyStates As Object = Nothing

        Protected Overrides Sub OnDrawingManagerChanged(ByVal e As EventArgs)
            If (DrawingManager = DrawManagers.LightColorDrawManager) Then
                Dim manager As LightColorDrawManager = CType(DrawManager, LightColorDrawManager)
                manager.SetCategoryBackgroundColors(Color.FromArgb(199, 218, 255), Color.White)
                manager.SetSubCategoryBackgroundColors(Color.FromArgb(197, 242, 191), Color.White)
            End If
            If (DrawingManager = DrawManagers.CustomDrawManager) Then
                propertyStates = SavePropertiesStates(PropertyStateFlags.All)
                'GridBackColor = Color.Black
                'GridForeColor = Color.FromArgb(192, 192, 192)
                'GridColor = Color.FromArgb(43, 43, 64)
                Dim propEnum As PropertyEnumerator = FirstProperty

                While (propEnum <> propEnum.RightBound)
                    If propEnum.Property.IsSetBackColor Then
                        propEnum.Property.BackColor = Color.Empty
                    End If
                    If propEnum.Property.IsSetForeColor Then
                        propEnum.Property.ForeColor = Color.Empty
                    End If
                    Dim propValue As PropertyValue = propEnum.Property.Value
                    If (Not (propValue) Is Nothing) Then
                        If propEnum.Property.Value.IsSetBackColor Then
                            propEnum.Property.Value.BackColor = Color.Empty
                        End If
                        If propEnum.Property.Value.IsSetForeColor Then
                            propEnum.Property.Value.ForeColor = Color.Empty
                        End If
                    End If
                    propEnum.MoveNext()

                End While
                Dim manager As LightColorDrawManager = CType(DrawManager, LightColorDrawManager)
                If (Not (manager) Is Nothing) Then
                    manager.SetCategoryBackgroundColors(Color.FromArgb(65, 76, 96), Color.FromArgb(65, 76, 96))
                    manager.SetSubCategoryBackgroundColors(Color.FromArgb(49, 49, 57), Color.FromArgb(49, 49, 57))
                    manager.UseBoldFontForCategories = True
                End If
            Else
                'GridBackColor = SystemColors.Window
                'GridForeColor = SystemColors.ControlText
                'GridColor = SystemColors.ActiveBorder
                If (Not (propertyStates) Is Nothing) Then
                    RestorePropertiesStates(propertyStates)
                    propertyStates = Nothing
                End If
            End If
            MyBase.OnDrawingManagerChanged(e)
        End Sub

        Private _mouseStart As Point

        Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
            If (e.Button = MouseButtons.Left) Then
                Dim args As SPGMouseEventArgs = CType(e, SPGMouseEventArgs)
                If (Not (args) Is Nothing) Then
                    If ((args.HitTest = HitTests.LeftColumn) _
                                OrElse (args.HitTest = HitTests.Label)) Then
                        _mouseStart = New Point(args.X, args.Y)
                        '                    LeftColumnWidth = LeftColumnWidth * 2;
                        '                        Cursor = Cursors.Hand;
                    End If
                End If
            End If
            MyBase.OnMouseDown(e)
        End Sub

        Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
            MyBase.OnMouseMove(e)
            If ((_mouseStart <> Point.Empty) _
                        AndAlso (e.Button = MouseButtons.Left)) Then
                '                Cursor = Cursors.Hand;
                Dim offset As Integer = ((e.Y - _mouseStart.Y) _
                            / BasicPropertyHeight)
                If (offset < 0) Then
                    Dim i As Integer = 0
                    Do While (i _
                                < (offset * -1))
                        Win32Calls.SendMessage(InternalGrid.Handle, Win32Calls.WM_VSCROLL, CType(Win32Calls.MakeLong(Win32Calls.SB_LINEDOWN, 0), IntPtr), IntPtr.Zero)
                        i = (i + 1)
                    Loop
                    _mouseStart.Y = (_mouseStart.Y _
                                + (offset * BasicPropertyHeight))
                ElseIf (offset > 0) Then
                    Dim i As Integer = 0
                    Do While (i < offset)
                        Win32Calls.SendMessage(InternalGrid.Handle, Win32Calls.WM_VSCROLL, CType(Win32Calls.MakeLong(Win32Calls.SB_LINEUP, 0), IntPtr), IntPtr.Zero)
                        i = (i + 1)
                    Loop
                    _mouseStart.Y = (_mouseStart.Y _
                                + (offset * BasicPropertyHeight))
                End If
            End If
        End Sub

        Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
            If (_mouseStart <> Point.Empty) Then
                '                LeftColumnWidth = LeftColumnWidth / 2;
                _mouseStart = Point.Empty
                Cursor = Cursors.Default
            End If
            MyBase.OnMouseUp(e)
        End Sub
    End Class
End Namespace 

Open in new window

Here is PointFConverter.vb:
Imports System
Imports System.Text
Imports System.ComponentModel
Imports System.Globalization
Imports System.Drawing
Imports System.Reflection

Namespace WindowsApplication

    Public Class PointFConverter
        Inherits ExpandableObjectConverter

        Public Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As Type) As Boolean
            If (sourceType = GetType(System.String)) Then
                Return True
            End If
            Return MyBase.CanConvertFrom(context, sourceType)
        End Function

        Public Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object) As Object
            Dim str As String = CType(value, String)
            If (str Is Nothing) Then
                Return MyBase.ConvertFrom(context, culture, value)
            End If
            Dim str2 As String = str.Trim
            If (str2.Length = 0) Then
                Return Nothing
            End If
            If (culture Is Nothing) Then
                culture = CultureInfo.CurrentCulture
            End If
            Dim ch As Char = culture.TextInfo.ListSeparator(0)
            Dim strArray() As String = str2.Split(New Char() {ch})
            Dim numArray() As Single = New Single(strArray.Length) {}
            Dim converter As TypeConverter = TypeDescriptor.GetConverter(GetType(System.Single))
            Dim i As Integer = 0
            Do While (i < numArray.Length)
                numArray(i) = CType(converter.ConvertFromString(context, culture, strArray(i)), Single)
                i = (i + 1)
            Loop
            If (numArray.Length <> 2) Then
                Throw New ArgumentException("Parse failed.")
            End If
            Return New PointF(numArray(0), numArray(1))
        End Function

        Public Overrides Function CanConvertTo(ByVal context As ITypeDescriptorContext, ByVal destinationType As Type) As Boolean
            If (destinationType = GetType(System.String)) Then
                Return True
            End If
            Return MyBase.CanConvertTo(context, destinationType)
        End Function

        Public Overrides Function ConvertTo(ByVal context As ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As Type) As Object
            If (destinationType Is Nothing) Then
                Throw New ArgumentNullException("destinationType")
            End If
            If (TypeOf value Is PointF) Then
                If (destinationType = GetType(System.String)) Then
                    Dim point As PointF = CType(value, PointF)
                    If (culture Is Nothing) Then
                        culture = CultureInfo.CurrentCulture
                    End If
                    Dim separator As String = (culture.TextInfo.ListSeparator + " ")
                    Dim converter As TypeConverter = TypeDescriptor.GetConverter(GetType(System.Single))
                    Dim strArray() As String = New String((2) - 1) {}
                    Dim num As Integer = 0
                    strArray(num) = converter.ConvertToString(context, culture, point.X)
                    strArray(num + 1) = converter.ConvertToString(context, culture, point.Y)
                    num += 2
                    Return String.Join(separator, strArray)
                End If
                If (destinationType = GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor)) Then
                    Dim point2 As PointF = CType(value, PointF)
                    Dim constructor As ConstructorInfo = GetType(PointF).GetConstructor(New Type() {GetType(System.Single), GetType(System.Single)})
                    If (Not (constructor) Is Nothing) Then
                        Return New System.ComponentModel.Design.Serialization.InstanceDescriptor(constructor, New Object() {point2.X, point2.Y})
                    End If
                End If
            End If
            Return MyBase.ConvertTo(context, culture, value, destinationType)
        End Function

        Public Overrides Function GetCreateInstanceSupported(ByVal context As ITypeDescriptorContext) As Boolean
            Return True
        End Function

        Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As System.Collections.IDictionary) As Object
            If (Not (propertyValues) Is Nothing) Then
                Return New PointF(CType(propertyValues("X"), Single), CType(propertyValues("Y"), Single))
            Else
                Return Nothing
            End If
        End Function
    End Class
End Namespace 

Open in new window


Regards,
Leigh
Avatar of kaufmed
kaufmed
Flag of United States of America image

It would be helpful if you pointed out which line(s) are in error so that we don't have to look over 900+ lines of code we didn't write in order to track down the relevant code  : \
Avatar of LeighWardle

ASKER

Sorry about that.

6 of the errors are the same as Line 2 in this function:

            Public Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As Type) As Boolean
                If (sourceType = GetType(System.String)) Then
                    Return True
                End If
                Return MyBase.CanConvertFrom(context, sourceType)
            End Function

Open in new window


The 7th error involves this statement:

If (destinationType = GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor)) Then

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks, kaufmed, that did the trick.

Regards,
Leigh