Community
Showing results for 
Search instead for 
Do you mean 
Reply

Is it possible to Sort the ContactFieldDescriptors collection?

Copper Super Contributor
Posts: 88
Country: USA

Is it possible to Sort the ContactFieldDescriptors collection?

I'd like to sort the ContactFieldDescriptors list by DisplayName. Here is my code:

 

    Dim cFields() As act.framework.contacts.contactfielddescriptor =     Me.HostApplication.ActFramework.Contacts.GetContactFieldDescriptors


    cFields.Sort()  ' Is this how you sort? If so, what are the parameters?

 

Any suggestions/sample code?

 

Thanks!

Employee
Posts: 1,163
Country: USA

Re: Is it possible to Sort the ContactFieldDescriptors collection?

It wouldn't be that simple. The collection used for field descriptors doesn't have a sort method, it can be filtered but you'd have to implement your own sort.

Matthew Wood
Act! SDK Support
Community Moderator
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Is it possible to Sort the ContactFieldDescriptors collection?

If you are using the field Descriptors in a combobox in the UI let the combo box do the heavy lifting.

 

'Add a ComboBox to the form named myComboBox

 

' On the form new event attach the fields descriptors to the drop down

Me.myComboBox.Items.AddRange(Me.HostFramework.Contacts.GetContactFieldDescriptors())

Me.myComboBox.DisplayMember ="DisplayName"

Me.myComboBox.Sorted =True

 

' On the ComboBox change event get the selected field descriptor

PrivateSub myComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlescboFields.SelectedIndexChanged

 

Dim SelectedFieldDescriptor AsAct.Framework.Contacts.ContactFieldDescriptor

 

' Set the selected FieldDesctriptor

SelectedFieldDescriptor =

DirectCast(DirectCast(DirectCast(sender, System.Windows.Forms.ComboBox).SelectedItem, System.Object), Act.Framework.Contacts.ContactFieldDescriptor)

 

EndSub

 

Hope this helps

-- Jim Durkin