UI Type Editor question


Author
Message
Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
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

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Thanks Ben that was exactly what I was looking for half the night. I owe ya a drink or 4

Thanks Again

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
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?

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
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


Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
This is Awesome!! Thanks alot for the help.. Feel like I just opened my eyes after walking around with em closed!!
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search