By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

how can I use typeconverter and a database string in the propertyg

P: n/a
I am trying to use the property grid in an app I am creating. I am currently
using the examply I got from the codeproject site with the propertybags, if
that rings a bell. I have created a typeconverter that converts a string in
to a dropdown list, a common issue. I am now trying to get this list filled
with options coming out of my database instead of having to hard code them in
the code on the class side as for instance is done in the snip down here:
Public Class dropdownconv
Inherits StringConverter
'Override the GetStandardValuesSupported method to indicate that this
object supports a standard set of values.
'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 GetStandardValuesSupported( _
ByVal context As ITypeDescriptorContext) As Boolean
Return True
End Function

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

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
End Class

Most examples I have seen use the hardcoded list in the class. My question
is what is the best way to transfer a string I created from my code to this
type converter, so that I can use this converter a general one for all the
strings I want to change to a dropdown list in the property grid. I have
searched the web and couldn't find anything on it. Maybe it is that
obvious....... Anyway some references to articles or just plain examples are
very much appreciated.

Thanks in advance

David J
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.