PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?RGF2aWQgSg==?=
Guest
Posts: n/a
 
      24th Aug 2004
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.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
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a TypeConverter instead of Type.GetType(String) Keith Patrick Microsoft Dot NET Framework 4 23rd Sep 2006 08:10 PM
Database String BobLaughland Microsoft ASP .NET 1 28th Feb 2006 04:58 AM
PropertyGrid String List TypeConverter/Desciptor =?Utf-8?B?Ui4gTmFjaHRzdHVybQ==?= Microsoft VB .NET 0 6th Dec 2005 08:05 AM
Find string inside a Database String Field =?Utf-8?B?TnVubyBHdWVycmE=?= Microsoft Access Form Coding 1 3rd Nov 2005 06:43 PM
TypeConverter not used? Iulian Ionescu Microsoft Dot NET Framework Forms 0 8th Dec 2003 03:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:50 PM.