Re: ?Propertygrid and dropdown list from database
From: David J (DavidJ_at_discussions.microsoft.com)
Date: 08/26/04
- Next message: Adam Nowotny: "Get application associated with a file extension (registry?)"
- Previous message: Cor Ligthert: "Re: Changing the CultureInfo"
- In reply to: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Next in thread: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Reply: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Aug 2004 04:31:02 -0700
Hi Cor,
Thanks for the reply. The thing is I want to use the same typeconverter to
populate different property options in the property grid. For instance if you
look at the property for a company. I want to have a list of departments,
which the user can setup and then I want a list of employer types, eg
manager, contractor etc... also coming from my database.
Department: Accounting
Employer Type: Manager
Name: Text
I have managed to get the dropdown list to work by making the string public.
Public _States As String()
In my code I would now define the string I want per property to go into the
typeconverter. However when I look at my property grid when I run the code
all the dropdown list are populated with the latest string so for instance if
I firstly defined the departments and then the employertypes all the
department options will be filled with employer types as well. The code I am
using to create my properties is based on the propertbag example in
www.codenet.com if that makes it any clearer.
I define my strings between the adding of the new properties to the
propertybag
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
bag3 = New PropertyTable()
mdSystem.ilist1 = New String() {"1", "2"}
bag3.Properties.Add(New PropertySpec("Company", GetType(String),
"Main", Nothing, Nothing, GetType(System.Drawing.Design.UITypeEditor),
GetType(DropDownconv)))
mdSystem.ilist1 = New String() {"3", "4"}
bag3.Properties.Add(New PropertySpec("Department", GetType(String),
"Main", Nothing, Nothing, GetType(System.Drawing.Design.UITypeEditor),
GetType(DropDownConv)))
bag3.Properties.Add(New PropertySpec("Name",
GetType(String), "Main", "Main", "er"))
bag3.Properties.Add(New PropertySpec("Country", GetType(arr),
"Main", "Location", Nothing))
Dim ps As New PropertySpec("Status", GetType(String),
"Information", "Status of the item", "C")
ps.Attributes = New Attribute() {ReadOnlyAttribute.Yes}
bag3.Properties.Add(ps)
Add any initialization after the InitializeComponent() call
bag3("Company") =Nothing
bag3("Department") =Nothing
bag3("Country") = Nothing
bag3("Name") = "Test"
end sub
Thanks
DJ
"Cor Ligthert" wrote:
> David
>
> Maybe you can do the problem step by step and tell what first part is not
> working and give us the documentation for that.
>
> Moreover, what is it you want to archieve without using that closed box and
> why are you not making a on first sight easy solution not new.
>
> When you are able to completly new, than that will make you more sure for
> future as well, than depending on a closed box.
>
> Just my thought,
>
> Cor
>
>
> "David J" <DavidJ@discussions.microsoft.com> schreef in bericht
> news:74D714F2-81D8-4D8B-8AF3-B080641DD701@microsoft.com...
> > Hi,
> > I am trying to write an app where the users would have to define for
> > instance company departments where employer would work. These departments
> are
> > store in my database. In the user interface, where the user has to enter
> the
> > employers, I am trying to use the propertygrid. For the department I want
> to
> > use a dropdownlist filled with the options from the database. I have got a
> > typeconverter that converts a sting into a dropdownlist, but this is only
> > hardcoded. I am not able to pass a string created from my database into
> the
> > typeconverte. The converter looks like this
> > 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
> >
> > Can you give me some ideas on how to continue?
> >
> > Thanks
> > David J
> >
>
>
>
- Next message: Adam Nowotny: "Get application associated with a file extension (registry?)"
- Previous message: Cor Ligthert: "Re: Changing the CultureInfo"
- In reply to: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Next in thread: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Reply: Cor Ligthert: "Re: ?Propertygrid and dropdown list from database"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|