473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Hi,
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
0 1264

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joăo Santa Bárbara | last post by:
Hi all i have a class that i have made and i made an Typeconverter as well, and my problem is the code genereated in my form is Dim ClassTest1 As TestApplication.ClassTest = New...
2
by: kw | last post by:
I'm getting different behavior from what I would expect and was hoping someone could clue me in. At run time I need to examine a property of an object for a custom TypeConverter, then use that...
1
by: Sky Sigal | last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols) I've been looking lately for a way to keep the Properties panel for Controls 'clean'... My goal is to keep similar...
5
by: ljlevend | last post by:
Is there a TypeConverter that converts Doubles to percent values in a PropertyGrid? The Windows.Forms.Form.Opacity property seems to use the TypeConverter that I want. Thank you, Lance
0
by: Eric Hoch | last post by:
Hello, I'm writing a TypeConverter for a class which inherits arraylist, but deserializing it always results in an arraylist, which causes an InvalidCastException. If anyone can point out what...
0
by: R. Nachtsturm | last post by:
Hi, I would like to create a workable ExpandableObjectConverter for a String Collection (class inheriting from CollectionBase for example and only accepting/returning Strings via...
4
by: swartzbill2000 | last post by:
Hello, I have a TypeConverter for converting between this Enum and Strings. Public Enum DeviceNameEnum dnNone dn2500 dnMirror End Enum 'DeviceNameEnum
11
by: Rolf Welskes | last post by:
Hello, the problem seems to be complex and is in all developments of web-controls which uses own TypeConverter. For this I have here a simple demo-program of the problem: The Control-code: A...
1
by: --== Alain ==-- | last post by:
Hi, I 'm facing an interesting issue regarding a property and its TypeConverter. When i do not attach a TypeConverter to this property, all custom properties of my custom control are displayed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.