Groups | Blog | Home
all groups > dotnet compact framework > february 2006 >

dotnet compact framework : looking for help with PIMItemCollection Find method



lansalot NO[at]SPAM gmail.com
2/14/2006 3:52:04 PM
Hi

I'm struggling with searching the Contacts on my PocketPC with
VS2005/.NET cf2 and hope someone can help please.

Specifically, the documentation for the Find method is a bit lacking
(to my eyes). You can see it here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/M_Microsoft_WindowsMobile_PocketOutlook_PimItemCollection_Find_1_917213a7.asp

I have no idea what I should be passing in as some sort of valid
PropertyDescriptor, nor the Key for that matter.

Can someone please help with a little example, say the simplest "find
contact for surname = 'smith'" sort of thing?

My nearest try was:

Dim o As New OutlookSession
criteria = "[LastName] = " & ControlChars.Quote & "Smith" &
ControlChars.Quote
MsgBox(o.Contacts.Items.Find(c.Properties("LastName"), criteria))

But obviously that's nowhere near right.

Also tried MsgBox(o.Contacts.Items.Find(c.Properties("LastName"),
"Smith"))

Nothing found. And it's there alright. I've seen how to use the
Restrict method, but that's not really the appropriate one to be using
so I guess I should learn to do it properly.

Thanks in advance for any help.
Ilya Tumanov [MS]
2/14/2006 5:58:30 PM
Right, that is not obvious. IBindingList is not exactly designed to be used
by humans directly.

Here's some sample (it's in C# but should not be too hard to convert to VB):

OutlookSession os = new OutlookSession();


ContactCollection cc = os.Contacts.Items;


Contact c;


c = new Contact();

c.FirstName = "John";

c.LastName = "Doe";

cc.Add(c);

c = new Contact();

c.FirstName = "Jane";

c.LastName = "Smith";


cc.Add(c);

PropertyDescriptor pdContact =
TypeDescriptor.GetProperties(typeof(Contact))["LastName"];

// Should be something like this in VB:

// Dim pdContact as PropertyDescriptor =
TypeDescriptor.GetProperties(GetType(Contact)).Item("LastName");

int smithIndex = cc.Find(pdContact, "Smith");


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

[quoted text, click to view]

lansalot NO[at]SPAM gmail.com
2/15/2006 1:34:03 AM
Many thanks for that Ilya.

Looking at your solution, I doubt I would have been able to work that
out just by staring at the documentation.

Many thanks for your help :)

[quoted text, click to view]
AddThis Social Bookmark Button