Click here to Skip to main content
Click here to Skip to main content

Using PropertyGrid Part-I

, 3 Feb 2003
Rate this:
Please Sign up or sign in to vote.
Explains about PropertyGrid and how to use, with detailed examples

Introduction

For my last project, I had a requirement where I can use PropertyGrid control. I tried to get information on that, from Microsoft and searching all over Internet, newsgroups, but I could find only a couple of articles from Microsoft. That's it, surprising, and not even a single example in VB.NET that compiles without errors and explains all in and outs of PropertyGrid control.

So, I decided to put all the information I collected, with fully functional working examples in VB.NET (which is my favorite) and let me tell you, it is the most complex control of all controls in VS.NET, yet very powerful and extremely useful, particularly in Custom Controls, and for Application Configuration settings. Visual Studio .NET property browser is also based upon the PropertyGrid.

Its so complex that I have to split this article into two parts. In this Part-I, I will explain how to use the basic properties and System resources, and in Part-II I will cover the advanced topic on using Custom Editors and User defined types.

Description

Open a new Windows application project using VB.NET. By default PropertyGrid is not visible in the Toolbox. So click on Customize Toolbox and add the PropertyGrid Control.

Adding the control, and dropping it on the Designer is pretty much the same like any other control. Fun starts after that. In order to use the PropertyGrid control, you have to provide a class as source to the PropertyGrid. Let's see a small example.

Imports System.ComponentModel
'''
<DefaultPropertyAttribute("Title")> _
Public Class SimpleProperties
    '''
    Private _Title As String
    Private _Show As Boolean
    Private _Number As Short
    '''
    <CategoryAttribute("Application"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("Enter Title for the application")> _
       Public Property Title() As String
           Get
               Return _Title
           End Get
           Set(ByVal Value As String)
               _Title = Value
           End Set
       End Property
    '''
    <CategoryAttribute("Application"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute("True"), _
       DesignOnly(False), _
       DescriptionAttribute("Show option")> _
       Public Property Show() As Boolean
           Get
               Return _Show
           End Get
           Set(ByVal Value As Boolean)
               _Show = Value
            End Set
       End Property
    '''
    <CategoryAttribute("Application"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute("0"), _
       DesignOnly(False), _
       DescriptionAttribute("Enter a number")> _
       Public Property Number() As Short
           Get
               Return _Number
           End Get
           Set(ByVal Value As Short)
               _Number = Value
           End Set
       End Property
    '''
End Class

To your form_load event add the following code:

PropertyGrid1.SelectedObject = New SimpleProperties()

Press F5 to run the project. Let's see the elements in the SimpleProperties.vb class

Imports System.ComponentModel Required for the Attributes
DefaultPropertyAttribute("Title") Indicates the default property for the PropertyGrid (i.e. where cursor is located when loaded)
CategoryAttribute("Application") Category attribute indicating the Category to which the property belongs to. Properties belonging to one category are grouped together.
Browsable(True) Indicates whether the property is shown in the grid
[ReadOnly](False) Indicates that the property is read-only or not
BindableAttribute(False) Indicates whether the property can be bound to a data source or not
DefaultValueAttribute("") Default value for the property
DesignOnly(False) If true, it indicates that the property is Read-only at run time
DescriptionAttribute("Enter Title for the application") Property Description. This description appears in the bottom when you click the property.

Then add the properties that you want to see in the PropertyGrid with right data types. Finally, assign the Class to the PropertyGrid's SelectedObject property. That's all we have to do. Rest is taken care by the PropertyGrid and you see the following output.

Let's add some System resources to the above class

Private _ApplicationSize As Size
Private _ApplicationLocation As Point
Private _ApplicationFont As System.Drawing.Font
Private _FontColor As System.Drawing.Color
Private _ApplicationIcon As System.Drawing.Icon
Private _ApplicationCursor As System.Windows.Forms.Cursor
Private _ApplicationLangugae As System.Globalization.CultureInfo
'''
<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Enter Application size")> _
Public Property ApplicationSize() As Size
    Get
        Return _ApplicationSize
    End Get
    Set(ByVal Value As Size)
        _ApplicationSize = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Enter Application Location")> _
Public Property ApplicationLocation() As Point
   Get
        Return ApplicationLocation
    End Get
    Set(ByVal Value As Point)
        _ApplicationLocation = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Select font for the application")> _
Public Property ApplicationFont() As System.Drawing.Font
    Get
        Return _ApplicationFont
    End Get
    Set(ByVal Value As System.Drawing.Font)
        _ApplicationFont = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Select font color")> _
Public Property FontColor() As System.Drawing.Color
    Get
        Return _FontColor
    End Get
    Set(ByVal Value As System.Drawing.Color)
        _FontColor = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Select icon for application")> _
Public Property ApplicationIcon() As System.Drawing.Icon
    Get
        Return _ApplicationIcon
    End Get
    Set(ByVal Value As System.Drawing.Icon)
        _ApplicationIcon = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Select application's cursor")> _
Public Property ApplicationCursor() As System.Windows.Forms.Cursor
    Get
        Return _ApplicationCursor
    End Get
    Set(ByVal Value As System.Windows.Forms.Cursor)
        _ApplicationCursor = Value
    End Set
End Property

<CategoryAttribute("Design"), DefaultValueAttribute(""), _
DescriptionAttribute("Select User language")> _
Public Property ApplicationLangugae() As System.Globalization.CultureInfo
    Get
        Return _ApplicationLangugae
    End Get
    Set(ByVal Value As System.Globalization.CultureInfo)
        _ApplicationLangugae = Value
    End Set
End Property

Again, PropertyGrid automatically populates Enumerations as drop down list, and system structures as collapsible sub sections.

Adding custom dropdown list

Now let's add a custom dropdown list which shows all states. In order to add a custom dropdown list, create a class that inherits from System.ComponentModel.TypeConverter or any other class, that was derived from TypeConverter class that matches your datatype. (check for System.ComponentModel namespace for all available custom type convert classes) So, for our example we inherit from System.ComponentModel.StringConverter

Public Class StatesList : Inherits System.ComponentModel.StringConverter

Override the GetStandardValuesSupported method to indicate that this object supports a standard set of values.

Public Overloads Overrides Function _
    GetStandardValues(ByVal context As _
    System.ComponentModel.ITypeDescriptorContext) _
    As System.ComponentModel.TypeConverter.StandardValuesCollection
    
    Return New StandardValuesCollection(_States)
End Function

Override the GetStandardValues method and return a StandardValuesCollection filled with our custom list.

Dim _States As String() = New String() {"Alabama", "Alaska",_
             "Arizona", "Arkansas", _
            "California", "Colorado", "Connecticut", "Delaware",_
            "Florida", "Georgia", _
            "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", _
            "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", _
            "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", _
            "Nebraska", "Nevada", "New Hampshire", _
            "New Jersey", "New Mexico", _
            "New York", "North Carolina", "North Dakota",_
            "Ohio", "Oklahoma", _
            "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", _
            "South Dakota", "Tennessee", "Texas", "Utah",_
            "Vermont", "Virginia",_
            "Washington", "West Virginia", "Wisconsin", "Wyoming"}

Public Overloads Overrides Function _
    GetStandardValues(ByVal context As _
    System.ComponentModel.ITypeDescriptorContext) _
    As System.ComponentModel.TypeConverter.StandardValuesCollection

    Return New StandardValuesCollection(_States)
End Function

Finally override the GetStandardValuesExclusive method. When set to false, it changes the dropdown list to Combo box (editable). If set to true, then its a simple list box (Read only).

Public Overloads Overrides Function _
    GetStandardValuesExclusive(ByVal context _
    As System.ComponentModel.ITypeDescriptorContext) _
    As Boolean
    
    Return True
End Function

Then apply the statesList class to the property by using the TypeConverterAttribute. Let's add a State property to the above example.

Private _State As String
'''
<TypeConverter(GetType(StatesList)), _
    CategoryAttribute("Custom List"), DefaultValueAttribute(""), _
    DescriptionAttribute("Select a state from the list")> _
    Public Property State() As String
    
    Get
        Return _State
    End Get
    Set(ByVal Value As String)
        _State = Value
    End Set
End Property

and here is the output.

Displaying custom data types with expandable properties

.NET framework data types like Size, Point when used in PropertyGrid, they are rendered as collapsible list and displays the sub elements. Let's implement a custom data type that duplicates the above functionality. In order to display a custom data type with a collapsible list, we need a TypeConverter, which converts an object type to string type and back to object. Framework also provides an ExpandableObjectConverter class (which is derived from TypeConverter class ) under System.ComponentModel namespace to implement this functionality. Create a class that defines your custom type. I am using Version number as custom type which will expand to Major,Minor,Build,Private parts.

Imports System.ComponentModel
Imports System.ComponentModel.Design.Serialization
'''
    <TypeConverter(GetType(ApplicationVersionConverter))> _
    Public Class ApplicationVersion
    '''
        Private _Major As Short
        Private _Minor As Short
        Private _Build As Short
        Private _Private As Short
        '''
        <DescriptionAttribute("Set the major part of version number")> _
        Public Property Major() As Short
            Get
                Return _Major
            End Get
            Set(ByVal Value As Short)
                _Major = Value
            End Set
        End Property
        '''
        
        <DescriptionAttribute("Set the minor part of version number")> _
        Public Property Minor() As Short
            Get
                Return _Minor
            End Get
            Set(ByVal Value As Short)
                Me._Minor = Value
            End Set
        End Property
        '''
        <DescriptionAttribute("Set the build part of version number")> _
        Public Property Build() As Short
            Get
                Return _Build
            End Get
            Set(ByVal Value As Short)
                Me._Build = Value
            End Set
        End Property
        '''
        <DescriptionAttribute("Set the private part of version number")> _
        Public Property [Private]() As Short
            Get
                Return _Private
            End Get
            Set(ByVal Value As Short)
                Me._Private = Value
            End Set
        End Property
        '''
End Class

All the above code is like the other examples, except TypeConverter attribute (<TypeConverter(GetType(ApplicationVersionConverter))>) which points to the TypeConvert class, that is used to convert our object to string and back to object. Let's implement the TypeConvert class

Friend Class ApplicationVersionConverter : Inherits ExpandableObjectConverter

Override the CanConvertTo function to indicate whether this converter can convert the object to the specified type.

 Public Overloads Overrides Function _
        CanConvertTo(ByVal context As _
        System.ComponentModel.ITypeDescriptorContext, _
        ByVal destinationType As System.Type) As Boolean

    If (destinationType Is GetType(ApplicationVersion)) Then
        Return True
    End If
    Return MyBase.CanConvertFrom(context, destinationType)
End Function

Override the CanConvertFrom function to indicate whether this converter can convert an object of one type to the type of this converter (in out case string to ApplicationVersion).

Public Overloads Overrides Function _
    CanConvertFrom(ByVal context As _
    System.ComponentModel.ITypeDescriptorContext,_
    ByVal sourceType As System.Type) As Boolean

    If (sourceType Is GetType(String)) Then
        Return True
    End If
    Return MyBase.CanConvertFrom(context, sourceType)
End Function

Override the ConvertFrom method to implement the logic to convert the string value to object. While converting make sure that the value parameter is a String.

Public Overloads Overrides Function _
    ConvertFrom(ByVal context As _
    System.ComponentModel.ITypeDescriptorContext, _
    ByVal culture As System.Globalization.CultureInfo, _
    ByVal value As Object) As Object
    
    If TypeOf value Is String Then
        Try
            Dim s As String = CType(value, String)
            Dim versionParts() As String
            Dim VersionString As String = ""
            versionParts = Split(s, ".")
            If Not IsNothing(versionParts) Then
                Dim _ApplicationVersion As _
                    ApplicationVersion = New ApplicationVersion()
                If Not IsNothing(versionParts(0)) Then 
                    _ApplicationVersion.Major = versionParts(0)
                If Not IsNothing(versionParts(1)) Then 
                    _ApplicationVersion.Minor = versionParts(1)
                If Not IsNothing(versionParts(2)) Then 
                    _ApplicationVersion.Build = versionParts(2)
                If Not IsNothing(versionParts(3)) Then 
                    _ApplicationVersion.Private = versionParts(3)
            End If
        Catch ex As Exception
            Throw New ArgumentException("Can not convert '" + _
                    value + "' to type ApplicationVersion")
        End Try
    End If
    
    Return MyBase.ConvertFrom(context, culture, value)
End Function

Override the ConvertTo method to implement the logic to convert your object back to string in a format you like. This is the value that is displayed for the parent. While converting make sure that the destinationType parameter is a String and that the value is the same type as the class.

Public Overloads Overrides Function 
         ConvertTo(ByVal context As _
         System.ComponentModel.ITypeDescriptorContext, _
         ByVal culture As System.Globalization.CultureInfo, _
         ByVal value As Object, ByVal _
         destinationType As System.Type) As Object

         If (destinationType Is GetType(System.String) AndAlso _
                  TypeOf value Is ApplicationVersion) Then
            
            Dim _ApplicationVersion As _
                ApplicationVersion = CType(value, ApplicationVersion)
            ' build the string as "Major.Minor.Build.Private"
            Return _ApplicationVersion.Major & "."_
                & _ApplicationVersion.Minor & "." & _
                _ApplicationVersion.Build & "." _
                & _ApplicationVersion.Private
        End If
        Return MyBase.ConvertTo(context, culture, value, destinationType)
End Function

and here is the final output for this article.

In the source code I have a much elaborated example, which mimic's the SQLConnectsting property.

Notes & To-Do features

In the next article I will explain about using custom editors to display properties like the docking, Graphics and tabs.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Sreenivas Vemulapalli
Web Developer
United States United States
Working as consultant in Client/server,Web Development, Automation areas using C#,Vb,Vb.net,Asp.net,Sql Server,Xml,Html&Dhtml etc..
Looking for a challenging project in .NET

Comments and Discussions

 
Generaldynamic / runtime drop down list of States PinmemberGrantS19-Dec-04 11:37 
GeneralRe: dynamic / runtime drop down list of States PinmemberDavid from the UK8-Jul-05 8:55 
GeneralRe: dynamic / runtime drop down list of States PinmemberMarkus Dahl17-Sep-05 12:01 
GeneralRe: dynamic / runtime drop down list of States Pinmemberoddtim15-Nov-06 6:25 
QuestionRe: dynamic / runtime drop down list of States Pinmemberflysnof12-Oct-05 19:55 
AnswerRe: dynamic / runtime drop down list of States PinmemberTyler W. Cox20-Jul-07 5:28 
GeneralToolTip in PropertyGrid PinmemberXenaUndercover16-Dec-04 0:06 
GeneralDerived Class Problem Pinmembercystech24-Nov-04 5:33 
I am trying to create a control from a derived TreeView Class. The idea is to pass information that relates to SQL Datasets. The item I'm adding is my own type called branch data and uses a collection editor to allow the user to enter data that corresponds to each branch in the treeview. I want the imageindex and selectedimageinex   to use the imagelist that is selected in the control as to not confuse the user. I'm currently using Shadows on the Imagelist items in the control in order to capture the selected imagelist the user selects. However now it seems that the node.imageindex   is unaware that an imagelist has been selected. In other words it doesn't show an icon no matter what index I give it. Any help would be appreciated. I've included the code I'm currently using below. Sorry about the length.
 
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.Serialization
<ToolboxBitmap("C:\icons2\63.ICO")> _
Public Class TreeViewData
      Inherits System.Windows.Forms.TreeView
 
      Private m_colBranchDatas As BranchDataCollection = New BranchDataCollection
 

#Region " Windows Form Designer generated code "
 
      Public Sub New()
            MyBase.New()
 
            'This call is required by the Windows Form Designer.
            InitializeComponent()
 
            'Add any initialization after the InitializeComponent() call
 
            m_colBranchDatas = New BranchDataCollection
            Dim m_Imagelist As ImageList = Me.ImageList
      End Sub
 
      'UserControl overrides dispose to clean up the component list.
      Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                  If Not (components Is Nothing) Then
                        components.Dispose()
                  End If
            End If
            MyBase.Dispose(disposing)
      End Sub
 
      'Required by the Windows Form Designer
      Private components As System.ComponentModel.IContainer
 
      'NOTE: The following procedure is required by the Windows Form Designer
      'It can be modified using the Windows Form Designer.
      'Do not modify it using the code editor.
      Private Sub InitializeComponent()
 
            Me.Name = "MyBranchDataLabel"
            Me.Size = New System.Drawing.Size(384, 192)
 
      End Sub
 
#End Region
 
      '________________________________________________________________________________
      '
      'BranchDatas
      '________________________________________________________________________________
      Shared m_imageList As ImageList
      Shadows Property ImageList() As ImageList
            Get
                  Return m_imageList
            End Get
            Set(ByVal Value As ImageList)
                  m_imageList = Value
                  Invalidate()
            End Set
      End Property
      Private m_ImageIndex As Integer = -1
      <Editor("System.Windows.Forms.Design.ImageIndexEditor", _
      GetType(System.Drawing.Design.UITypeEditor)), TypeConverter(GetType(ImageIndexConverter))> _
      Shadows Property ImageIndex() As Integer
            Get
                  'Check to make sure the ImageList is something.
                  If Not (m_imageList Is Nothing) Then
                        Return m_ImageIndex
                  End If
            End Get
            Set(ByVal Value As Integer)
                  m_ImageIndex = Value
                  Invalidate() 'This will refresh the control. Any drawing done using this property will redraw itself with the new selection
            End Set
      End Property
      Private m_SelectedImageIndex As Integer = -1
      <Editor("System.Windows.Forms.Design.ImageIndexEditor", _
      GetType(System.Drawing.Design.UITypeEditor)), TypeConverter(GetType(ImageIndexConverter))> _
      Shadows Property SelectedImageIndex() As Integer
            Get
                  'Check to make sure the ImageList is something.
                  If Not (m_imageList Is Nothing) Then
                        Return m_SelectedImageIndex
                  End If
            End Get
            Set(ByVal Value As Integer)
                  m_SelectedImageIndex = Value
                  Invalidate() 'This will refresh the control. Any drawing done using this property will redraw itself with the new selection
            End Set
      End Property
 

      <Editor(GetType(BranchDataCollectionEditor), GetType(System.Drawing.Design.UITypeEditor)), Category("Collections"), _
      DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
      Public Property BranchDataItems() As BranchDataCollection
            Get
                  Return m_colBranchDatas
            End Get
            Set(ByVal Value As BranchDataCollection)
                  m_colBranchDatas = Value
            End Set
      End Property
 
      Public Class BranchDataCollection
            Inherits CollectionBase
            '````````````````````````````````````````````````````````````````````````````````
            'Methods
            '````````````````````````````````````````````````````````````````````````````````
            '________________________________________________________________________________
            '
            'Add
            '________________________________________________________________________________
            Public Function Add(ByVal v_objBranchData As BranchData) As Int32
                  Return MyBase.InnerList.Add(v_objBranchData)
            End Function
 
            Public Sub AddRange(ByVal e As BranchData())
                  Me.InnerList.AddRange(e)
            End Sub
 

 
            Public Sub Remove(ByVal e As BranchData)
                  Me.InnerList.Remove(e)
            End Sub
 
            '________________________________________________________________________________
            '
            'item
            '________________________________________________________________________________
            Public Property Item(ByVal index As Integer) As BranchData
                  Get
                        Return (CType(MyBase.InnerList.Item(index), BranchData))
                  End Get
                  Set(ByVal Value As BranchData)
                        Me.InnerList.Item(index) = Value
                  End Set
            End Property
 
      End Class
 
      <DesignTimeVisible(False)> _
      Public Class BranchData
            Private m_DataSet As String
            Private m_SortKey As String
            Private m_IndexKey As String
            Private m_DefaultText As String
            Private m_IconIndex As Integer
            Private ms_ImageList As ImageList = m_imageList
            Private m_SelectedIconIndex As Integer
            Public Sub New()
 
            End Sub
 
            Public Sub New(ByVal v_strDataSet As String, ByVal v_strSortKey As String, ByVal v_intIndex As Integer, ByVal v_intIconIndex As Integer, ByVal v_intSelectedIconIndex As Integer, ByVal v_ImageList As ImageList, ByVal v_DefaultText As String)
                  m_DataSet = v_strDataSet
                  m_SortKey = v_strSortKey
                  m_IndexKey = v_intIndex
                  m_DefaultText = v_DefaultText
                  m_IconIndex = v_intIconIndex
                  m_SelectedIconIndex = v_intSelectedIconIndex
                  ms_ImageList = v_ImageList
            End Sub
            <Category("Branch DataSet")> _
         Public Property DataSet() As String
                  Get
                        Return m_DataSet
                  End Get
                  Set(ByVal Value As String)
                        m_DataSet = Value
                  End Set
            End Property
            <Category("Branch DataSet")> _
         Public Property SortKey() As String
                  Get
                        Return m_SortKey
                  End Get
                  Set(ByVal Value As String)
                        m_SortKey = Value
                  End Set
            End Property
            <Category("Branch DataSet")> _
                  Public Property IndexKey() As String
                  Get
                        Return m_IndexKey
                  End Get
                  Set(ByVal Value As String)
                        m_IndexKey = Value
                  End Set
            End Property
            <Category("Branch DataSet")> _
                  Public Property DefaultText() As String
                  Get
                        Return m_DefaultText
                  End Get
                  Set(ByVal Value As String)
                        m_DefaultText = Value
                  End Set
            End Property
            <Browsable(False)> _
                  Public Property ImageList() As ImageList
                  Set(ByVal Value As ImageList)
                        ms_ImageList = Value
                  End Set
                  Get
                        Return ms_ImageList
                  End Get
            End Property
            <Category("Branch DataSet"), DefaultValue(-1), _
               TypeConverter(GetType(ImageIndexConverter)), _
               Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design", GetType(System.Drawing.Design.UITypeEditor))> _
            Public Property IconIndex() As Integer
                  Get
                        If m_imageList Is Nothing Then
                              m_IconIndex = -1
                        End If
                        Return m_IconIndex
                  End Get
                  Set(ByVal Value As Integer)
                        m_IconIndex = Value
                  End Set
            End Property
            <Category("Branch DataSet"), DefaultValue(-1), _
                     TypeConverter(GetType(ImageIndexConverter)), _
                     Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design", GetType(System.Drawing.Design.UITypeEditor))> _
               Public Property SelectedIconIndex() As Integer
                  Get
                        If m_imageList Is Nothing Then
                              m_SelectedIconIndex = -1
                        End If
                        Return m_SelectedIconIndex
                  End Get
                  Set(ByVal Value As Integer)
                        m_SelectedIconIndex = Value
                  End Set
            End Property
      End Class
 
      Public Class BranchDataBranch
            Inherits BranchData
            Implements IComponent
 
            Public Event Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Implements System.ComponentModel.IComponent.Disposed
            Private mySite As ISite
            <Browsable(False)> _
            Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site
                  Get
                        Return mySite
                  End Get
                  Set(ByVal Value As System.ComponentModel.ISite)
                        mySite = Value
                  End Set
            End Property
 
            Public Sub Dispose() Implements System.IDisposable.Dispose
                  ''Nothing to clean
                  RaiseEvent Disposed(Me, New EventArgs)
 
            End Sub
      End Class
 
      <TypeConverter(GetType(BranchData_TypeConverter))> _
      Public Class BranchData_TC
            Inherits BranchData
 
            Public Sub New()
                  MyBase.New()
 

            End Sub
 
            Public Sub New(ByVal DataSet As String, ByVal SortKey As String, ByVal Index As Integer, ByVal IconIndex As Integer, ByVal SelectedIconIndex As Integer, ByVal parentImageList As ImageList, ByVal DefaultText As String)
                  MyBase.New(DataSet, SortKey, Index, IconIndex, SelectedIconIndex, parentImageList, DefaultText)
            End Sub
      End Class
 
      Friend Class BranchDataCollectionEditor
            Inherits CollectionEditor
 
            Public Sub New(ByVal type As Type)
                  MyBase.New(type)
            End Sub
 

            Protected Overrides Function CreateNewItemTypes() As System.Type()
                  Return New Type() {GetType(BranchDataBranch), GetType(BranchData_TC)}
            End Function
 
      End Class
 
      Friend Class BranchData_TypeConverter
            Inherits ExpandableObjectConverter
 
            Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean
 
                  If (destinationType Is GetType(InstanceDescriptor)) Then
                        Return True
                  Else
                        Return MyBase.CanConvertTo(context, destinationType)
                  End If
            End Function
      End Class
End Class
 

 

GeneralPassword Fields PinsussAnonymous11-Nov-04 6:37 
GeneralJust implemented it. PinsussAnonymous11-Nov-04 11:47 
GeneralRe: Just implemented it. Pinmembercsilvias24-Nov-05 23:13 
GeneralIs posible show only custom properties (hiden the properties added by inherits) Pinmemberkh30qs11-Nov-04 6:25 
QuestionHow to Saving/Retrieving custom data types with expandable properties PinmemberPhilapi19-Oct-04 21:51 
QuestionHow to list...System.Type Pinmemberbismark5-Oct-04 13:05 
GeneralPropertyGrid Drop-Drown List in Automation Project PinsussAnonymous31-Jul-04 21:55 
GeneralRe: PropertyGrid Drop-Drown List in Automation Project PinsussAnonymous22-Aug-04 23:28 
GeneralRe: PropertyGrid Drop-Drown List in Automation Project PinmemberFelix Berman26-Sep-04 1:26 
GeneralRe: PropertyGrid Drop-Drown List in Automation Project PinsussAnonymous9-Jan-05 6:23 
GeneralProperty Grid Item PinmemberGM_20-Jun-04 21:58 
GeneralChoosing the properties to show PinmemberMark Saccomandi1-Jun-04 2:16 
GeneralRe: Choosing the properties to show PinmemberMichelle Fox6-Oct-05 9:49 
GeneralPropertyGrid Ultimate MSDN Article PinmemberrawCoder11-May-04 2:27 
QuestionPart II? PinmemberMarcosB2-May-04 14:00 
GeneralExcellent PinmemberPaleyX4-Apr-04 5:45 
QuestionList of Controls ?? PinmemberD.T31-Mar-04 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 4 Feb 2003
Article Copyright 2002 by Sreenivas Vemulapalli
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid