Results 1 to 4 of 4

Thread: Getting a reference to a client form Propertygrid

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26

    Getting a reference to a client form Propertygrid

    I have a custom control with properties I want displayed in the property grid. This has gone really well so far. I want to implement a property with a dropdown, listing all other controls on the client form. If I do the following;
    <CategoryAttribute("Data Objects"), DefaultValueAttribute(""), _
    DescriptionAttribute("Select a related control from the list")> _
    Public Property ControlsOnForm() As String()
    Get
    Return _alCtrs
    End Get
    Set(ByVal Value As String())
    _alCtrs = Value
    End Set
    End Property

    Private Sub GetControlsOnForm()
    Dim i As Int16 = 0
    Dim alCtrs() As String
    For Each ctr As Control In Me.ParentForm.Controls
    ReDim Preserve alCtrs(i)
    alCtrs(i) = ctr.Name
    i += 1
    Next
    ControlsOnForm = alCtrs
    End Sub

    I get a String Collection Editor if I press the ellipse button. Is there a way I can change it so that I get a dropdown list instead?

    Thanks
    erimus

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Since the property is of string type you get the string editor if you made it of control type or a specific control type then it should automatically be a dropdown of controls and/or specific controls on the form. At least that is how it does it for Usercontrols anyway.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26
    Thanks Edneeis for your reply. I have tried your suggestion and changed the type from string to control. I now get the control Collection editor. Still no dropdown.

    Thanks
    erimus

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    26
    Thanks all who tried to help me solve this problem. I have found a solution. By changing the property inside my user control from an array to a variable then using an internal class that inherits from the stringConverter to implement my dropdown

    Public Shared _alCtrs() As String
    Private Function GetControlsOnForm() As String()
    Dim i As Int16 = 0
    Dim alCtrs() As String
    For Each ctr As Control In Me.ParentForm.Controls
    ReDim Preserve alCtrs(i)
    alCtrs(i) = ctr.Name
    i += 1
    Next
    Return alCtrs
    End Function

    Private _ctr As String
    <TypeConverter(GetType(ControlsConverter)), _
    CategoryAttribute("Data Objects"), DefaultValueAttribute(""), _
    DescriptionAttribute("Select a related control from the list")> _
    Public Property ControlsOnForm() As String
    Get
    Return _ctr
    End Get
    Set(ByVal Value As String)
    _ctr = Value
    End Set
    End Property

    Private Class ControlsConverter : Inherits StringConverter
    Public Overloads Overrides Function GetStandardValues(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection
    Return New StandardValuesCollection(_alCtrs)
    End Function
    '''

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


    End Class
    erimus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width