Using dynamic data in the PropertyGrid

G

Guest

Hi! Maybe I'm missing something, but I can't find an example of using dynamic
data within a propertygrid - in either VB or C#. I have the classic setup of
a listbox tied in to a propertygrid control. The item selected in the listbox
is passed to the propertygrid as the selected object. One of the properties
that I need in the grid is a drop down list which I can populate if it is
static [sample below]. What I can't figure out is how to us a dynamic list of
options in the drop down.

For example, the using the states example I see eveywhere, suppose the
states are stored in a database with an enabled field and I only want the
states that have been selected as enabled to be in the dropdown list. Does
that make sense? Can anyone help me out with a simple example? I've searched
the 'net and haven't seen an example of this yet. Or maybe its just me?!?

The data can be of any type at this point - array, hashtable, etc.

Imports System.ComponentModel

Public Class PlotStampOrientation : Inherits
System.ComponentModel.StringConverter

Private _Location As String() = New String() {"Lower Left", "Lower Right",
"Upper Left", "Upper Right"}

Public Overloads Overrides Function GetStandardValues(ByVal context As
System.ComponentModel.ITypeDescriptorContext) As
System.ComponentModel.TypeConverter.StandardValuesCollection
Return New StandardValuesCollection(_Location)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top