liquid8 Posted June 15, 2003 Posted June 15, 2003 I have 2 properties on a property grid.. depending on the first ones value, i want to return one of two different enums.. For instance, I have a multiple data types (file, image, etc) and then i have enumerations for each... for File: location, name, size for Image: height, width, size if you change the first property to file, the other property should be a dropdown list of the file enums, if it is changed to image, the other property should change to be a dropdown list of the image enums.. How can I do this? Thanks, LiQuiD8 Quote
liquid8 Posted August 8, 2003 Author Posted August 8, 2003 I have been searching and am still having trouble with this one... I may not have explained this very well... I have 2 values on a property grid. One of them I am trying to create a typeconverter that will return a standardvaluescollection, but the values it returns need to be dependant upon the value of the other property. Is there a way I can somehow pass a value to a typeconverter to accomplish this? Thanks, LiQuiD8 Quote
liquid8 Posted August 11, 2003 Author Posted August 11, 2003 In case anyone needs to know how I did this.... I was using a typeconverter and overriding GetStandardValues, but I needed to return a dynamic list of items based on another property value... Here's what I did: Public Overloads Overrides Function GetStandardValues(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.ComponentModel.TypeConverter.StandardValuesCollection Dim obj As Object = context.Instance Dim DataValues as new ArrayList If Typeof(obj) is Label Then DataValues.Add("Text: " & obj.Text) DataValues.Add("Left: " & obj.Left) DataValues.Add("Top: " & obj.Top) Elseif Typeof(obj) is Bitmap Then DataValues.Add("Image") DataValues.Add("Height: " & obj.Height) DataValues.Add("Width: " & obj.Width) End If Return New StandardValuesCollection(DataValues) End Function The important part is the context.Instance - this allows you to retrieve information about the object that contains the property associated with the TypeConverter. LiQuiD8 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.