StrataFrame Forum

UI Type Editor question

http://forum.strataframe.net/Topic3891.aspx

By Paul Chase - 10/27/2006

I am hoping someone has run into this.

I have a property of type string that I created a custom ui type editor for. This part is working great the editor pops up and the text is reflected back on the property sheet for that property. However the changes to the property value are not serialized back to the class unless I manually type something on the property sheet. 

Even though the text I type in custom editor is being reflected back to the property sheet property value some event or something is not firing to know that the value of that property has changed. 

Any ideas?

Paul

By StrataFrame Team - 10/27/2006

Whatever value you return from the EditValue() override within the type editor will be set back in the property sheet, but the value will not be set on the object.  Generally, you will need to use this:

context.PropertyDescriptor.SetValue(context.Instance, "MyValue")

Which uses the property descriptor to set the actual value on the design-time instance, which is then detected and serialized into the .designer.* file.

By Paul Chase - 10/27/2006

Thanks Ben that was exactly what I was looking for half the night. I owe ya a drink or 4

Thanks Again

By StrataFrame Team - 10/27/2006

So that worked?  I'm glad. Smile

Oh, and you're off the hook because I don't drink... unless you consider a chocolate milk shake a hard drink Wink

By Paul Chase - 10/27/2006

Lol I can handle that I'll make it a double!

How bout another question?

I have a property called report and its type is "xtrareportbase" which is my sublass of an xtrareport. Of course in the property sheet this is a dropdown but a devexpress xtrareport is not a component so I canot drag one onto the design surface to allow it to be selected from the combo.

I am thinking that I will have to follow the same idea of using a ui type editor and type converter and then use reflection to loop through the assemply to find all the report types in the project to be able to select the one i want and then update the property grid. Does this sound like I'm going down the right path or am I in the weeds again?

By StrataFrame Team - 10/27/2006

No, you're on the right track... in fact, that's what we do with the ListPopulation type editors.  Once you have an Assembly object, you can call GetTypes() which will return a Type array containing all of the public types (by default, but you can specify flags to grab the private types as well), and on each one you can check if Type.IsSubClassOf(GetType(xtrareport)) then add it to the list and once they select one of the types, then you can create a new instance of it and stuff it in the property value using that context.PropertyDescriptor.SetValue() method.
By Paul Chase - 10/27/2006

Something like this

Dim LoAssy As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()

For Each loType As Type In LoAssy.GetTypes()

If loType.IsSubclassOf(GetType(ReportEngine.XtraReportBase)) Then

populate combo or something

End If

Next

By Paul Chase - 10/27/2006

This is Awesome!! Thanks alot for the help.. Feel like I just opened my eyes after walking around with em closed!!
By StrataFrame Team - 10/27/2006

Something like that... however, you won't be able to get the executing assembly at design-time... you'll probably have to do this:

For Each loAssembly As Assembly In AppDomain.CurrentDomain.GetAssemblies()
    '-- Don't check the assembly if the name starts with System, DevExpress, Microsoft, etc.
    If loAssembly.Name.FullName.StartsWith("System") OrElse _ ' etc...  Then
        '-- Cycle through all of the types...
    End If
Next

By StrataFrame Team - 10/27/2006

Actually, now that I think about it, you can get the executing assembly, you just cannot get the entry assembly.  However, you might want to still use the AppDomain trick just in case your report is not located within the same assembly as your type editor.
By StrataFrame Team - 10/27/2006

Paul Chase (10/27/2006)
This is Awesome!! Thanks alot for the help.. Feel like I just opened my eyes after walking around with em closed!!

When I started with reflection, I felt like I was playing Doom3... you're walking around an absolutely huge, pitch-black room with nothing but a dinky flashlight, so you can only look at one thing at a time.  However, once you've gone through the game a few times, you can navigate the room by by touch because you know where everything is Smile

By Paul Chase - 10/27/2006

Perfect analogy! Lol now the problem is I am thinking about all sorts of other things I can do instead of the problem at hand Smile  Thanks alot for the help it rhelped me bypass a bunch of google time.