Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

custom UIEditors

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
keesp
Guest





PostPosted: Wed Jun 22, 2005 1:06 pm    Post subject: custom UIEditors Reply with quote

Hi,

I am trying to use a UniversalEditBox to edit the properties of an object. This seems to work fine, but for some properties, that use custom UItype editors (added through EditorAttributes) don't seem to work. Before I start debugging, I was wondering if the UniversalEditBox indeed uses UITypeEditors provided through the attributes (through reflection)

Thanks,

Kees
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jun 22, 2005 11:43 pm    Post subject: Reply with quote

Yes UniversalEditBox does use the UITypeEditors associated with a type or property. Exactly how this happens depends on whether you are using ObjectBinding or the programmatic data interface to populate the tree.

If you are using ObjectBinding then the GetCellData method sets the TypeEditor and TypeConverter properties of the CellData automatically using reflection to obtain the TypeEditor and TypeConverter associated with the particular property.

If you are not using ObjectBinding (and you don't set the TypeEditor or TypeConverter property yourself) then the UniversalEditBox will use reflection to get the TypeEditor and TypeConverter associated with the object passed to it.

In the latter case if the value passed to the UnversalEditBox is null it cannot do anything. It is also unable to handle the case where you apply the TypeEditor attribute to a property of the bound object (rather than a type). To handle these cases programmatically you need to set the TypeEditor and TypeConverter properties of CellData manually.

It can be a good idea to place a UniversalEditBox on a separate form and get the behaviour right there first before dealing with the extra complexity of having it embedded in the tree.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
keesp
Guest





PostPosted: Tue Jul 26, 2005 10:17 am    Post subject: Getting custom type editors to show in universal text box Reply with quote

Okay... I may need some help here...

I have an UniversalTextBox in a form, which I would like to open a filebrowser upon editing. So I declare:

this.universalEditBox1.Editor = new EcoChemie.Utils.ComponentModel.FolderBrowser();
this.universalEditBox1.Value = @"c:\";

The folder browser encapsulates a standard Browser dialog in a UITypeEditor.
I would expect the file browser to open when I click on the edit box, but instead I only can edit the string value.

What am I doing wrong?

Thanks,

Kees
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jul 26, 2005 10:33 am    Post subject: Reply with quote

I assume your FolderBrowser inherits from UITypeEditor - or else your assignment statement should fail. You also have to override the GetEditStyle method (and return Modal) and override the EditValue method to show your folder browser dialog and return the new value.

If you have done this then you should see an ellipses button displayed at the right of the UniversalEditBox which when you click on it displays your folder browser.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
keesp
Guest





PostPosted: Wed Jul 27, 2005 2:55 pm    Post subject: UITypeEditor issues Reply with quote

Okay,

The UITypeEditors we use are as you advised BUT...
Look at the following code example:

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
if (context != null && context.Instance != null)
return UITypeEditorEditStyle.Modal;
return base.GetEditStyle(context);
}

As you can see the TypeDescriptorContext is checked, and if it is null, we use the default GetEditStyle. The same check is done in EditValue. This is the same approach as we see in most articles on UIType editors

It appears that this context is null, so we don't get the behaviour we want.

Now I face two options:

1: either I have to do something additional in order to get a valid context
2: the check should be removed.

Option two is added, because we have found some information 1n the MSDN library and on the internet that suggest that the context is often null.

Could you advise me on this one?

Thanks,

Kees
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jul 27, 2005 10:46 pm    Post subject: Reply with quote

I don't think you need the check. Clearly the standard Microsoft editors for things like Images and colors don't do this - because they work just fine with UniversalEditBox Smile
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
keesp
Guest





PostPosted: Tue Aug 02, 2005 11:02 am    Post subject: ITypeDescriptorContext Reply with quote

I have looked into the ITypeDescriptorContext issue, and as far as I can see, a propertygrid fills in a PropertyDescriptorGridEntry..., which is the same as the provider!
I would like to suggest that virtualtree could do something similar (add the UnversalTextBox as ITypeDescriptorContext ) as I have the feeling that many users will experience problems using their custom UIEditors in virtualtree. As said earlier, most articles on creating UITypeEditors DO check the context being null, and so most users will follow a similar implementation.

Hope this may help make a great product even better!

Kees
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Aug 02, 2005 11:23 pm    Post subject: Reply with quote

OK we will look into this for the next release.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
keesp
Guest





PostPosted: Mon Aug 22, 2005 6:34 am    Post subject: Custom UI type editors Reply with quote

Everything seems to work fine in the 2.0 release. I only suspect (I'm not quite sure) that the GetEditStyle(ITypeDescriptorContext context) method still gets a null reference, instead of the universal edit box. This would really make all our custom editors work fine!

Kees
Back to top
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Aug 22, 2005 6:46 am    Post subject: Reply with quote

You may be correct. We will look at this and fix in the next minor update.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Aug 31, 2005 3:33 am    Post subject: Reply with quote

Version 2-0-2 has now been released. GetEditStyle is now passed the TypeDescriptorContext.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
keesp
Guest





PostPosted: Wed Oct 05, 2005 11:11 am    Post subject: Everything's working fine! Reply with quote

Hi,

The custom editors are working fine now! I think with these changes the UniversalEditBox has really become a powerful tool!

Thanks again,

Kees
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group