The blog of Eric Sibly; focusing on mountain biking, .NET development for the Desktop, Smartphone and PocketPC.

Tuesday, June 21, 2005

ItemId unique identifier…

In Windows Mobile 5.0 we have the ItemId class that is used to uniquely identify PIM and Messaging items. This class has a constructor that takes an integer, which is the unique code of the identifier which will load the appropriate PIM object. Nice :-)

Let’s say within my application I use the ChooseContactDialog class to select a Contact. (This is a really nice feature of Windows Mobile 5.0 and the corresponding Contact.ShowDialog and alike provide the means to write some really cool integrated applications with the PIM.)

Now I want to save the selected Contact for future reference, maybe store a reference in SQL CE. To do this we should save the unique identifier for the contact which as we know is represented by the ItemId. The only thing is that there is no publicly accessible property to get access to this integer value – which you would think would be perfectly logical?!?

All is not completely lost as I did manage to get access to this value via a hack; but it means outputting it as a string and converting back to an integer – ew! Code as follows:

// Show contact chooser.
ChooseContactDialog ccd = new ChooseContactDialog();
ccd.ShowDialog();

// Get the selected contact.
string text = ccd.SelectedContact.ItemId.ToString();
int id = Convert.ToInt32(text);

// Show the contact using the identifier.
Contact c = new Contact(new ItemId(id));
c.ShowDialog();

2 Comments:

Blogger Barton said...

This site gives away FREE tickets to Las Vegas shows. They have other great Las Vegas stuff including info about worlds greatest magic tricks tickets Check it out worlds greatest magic tricks tickets

11:50 am

 
Anonymous Anonymous said...

That sounds great, but I've seen very different opinions of online safety training aed sales

11:19 am

 

Post a Comment

<< Home