Community
Showing results for 
Search instead for 
Do you mean 
Reply

Dynamic Label Control - Source Code Only

Nickel Elite Contributor
Posts: 937
Country: USA

Dynamic Label Control - Source Code Only

[ Edited ]

Here is the source code to the Dynamic Label Control.

 

It's quite simple - a single class is all that's needed.  I've left some of my notes in the form of comments in the code.  

 

The code uses IMutableEntity interface (2010 or higher) and I get the feeling that I could make the same control work against any entity (right now it's specific to Contacts), but I've not been able to tackle that yet.

 

Also this would be a good launching point to do this kind of thing for controls other than Labels (like add a custom gauge control for example).  The one thing this doesn't do is wire up the control to binding for updating purposes (it's essentially read only), but you could, of course, add that.

 

 Let me know if there are any questions on the source - and if you do happen to improve upon this please repost it here.

 

 

Message Edited by alduet on 05-28-2010 11:17 AM
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Dynamic Label Control - Source Code Only

Hi Alan,

 

Thanks for your time today at the Perfecting ACT! conference.

 

I have just been having a quick play around with the controls using the source you've provided here, but have run into a problem that I have only just remembered was a question I had wanted to ask you but had forgotten! 

 

With the new API we use the MutableEntity interfaces and not the entity-specific interfaces as we did in the past but this now means that I have no documentation or working examples of how to precisely get a custom control to show the "Select Field" popup within the designer as we could perviously. If memory serves me right we need our control to implement the IMutableEntityFieldBoundControl thereby allowing a user to define which ACT! Field a custom control is bound to at runtime in the Layout designer.

 

Would it be possible for you to post up a working example or some code of this?

 

TIA

 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Nickel Elite Contributor
Posts: 937
Country: USA

Re: Dynamic Label Control - Source Code Only

Are you talking about an enumeration that shows all of the Contact Field Descriptors?

 

I think you'd need to recast that property as an enum then just populate the enum with a loop using Getcontactfielddescriptors at design time.

 

Allen

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Dynamic Label Control - Source Code Only

Hi Alan,

 

Ok, I feel a little red faced now since I had not really tried to understand the code I had written  a couple of years ago! Anyway, looking further into this from what I can gather to enable us to use the a CustomControl Designer class for our custom control we have to implement the FieldBoundControl not just the List.

 

Further into my code I see that to call up the Field Popup in the Designer we used to call on an entity specific _x_FieldDescriptorPickerForm(myCustomControl). This has been deprecated and is now Obsolete and we use the MutableEntityFieldDescriptorPickerForm which has 2 constructors, one is a default constrcutor and the other has not been documented other than the signature.

 

The real problem for me is the argument MutableEntityFieldBoundControlDesigner where I can't seem to be able to simply pass a new MutableEntityFieldBoundControlDesigner() into the method.

 

I hope that all makes little more sense!

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Nickel Elite Contributor
Posts: 937
Country: USA

Re: Dynamic Label Control - Source Code Only

Vivek - it was great meeting you in person, even if it was not for long.

 

I haven't used the MutableEntityFieldDescriptorPickerForm method, but if I understand what I think you want to do which is:

 

At design time for a custom control populate a property dropdownlist with the values of the entity field names for selection.

 

The way I would do this is to establish an Enum variable ala:

 

public Enum somename {In here I would cast a mutable entity into the entitytype I want then read each field descriptor name}

 

Then Add another public property and have the getter ans setters point to the variable.

 

If not mistaken .Net will expose this property with a drop down list and the item selected will be in your local variable 9which you can cast to string and use in code.

 

I'm a bit rusty on my dev skills, but I think this approach should work.

 

In an earlier effort I was considering writing an enum which represented the entities (Contact, Company, Groups etc...) then added that as a property - when selected a second property would enumerate the fields of the selected entity for selection (the label control is where this would have been useful), but I could never figure out how to get the field enumeration to trigger again once I changed the entity name in the first property.

 

Hope this helps.