how to filter and hide poom appointments in datagrid

N

None

hi there,

i am having a problem about how to filter and hide some of the
appointments in a datagrid. i am working on a wm5 calendar application
using c# 2005 and cf2.0. i built a datagrid with:

private AppointmentCollection apptcollection;
apptcollection = outlooksession.Appointments.Items;
dgrid.datasource = apptcollection;

everything seems fine as i can use the Restrict method to filter the
appointments that i want to display. however, the Restrict method
cannot handle criterion which is a bit more complicated, e.g.
Appointment.Location contains (not equals to) "Office". i guess what i
need to do is looping through the restricted apptcollection, and hide
or remove the rows that i do not want. i do not want to directly
remove the rows in apptcollection because it really causes the records
to be deleted from the database.

i know a dataview can do what i want, however it does not accept
apptcollection to be its source because apptcollection is not a
datatable, i.e.
DataView firstView = new DataView(apptcollection);
*** compile error ***
Argument '1': cannot convert from
'Microsoft.WindowsMobile.PocketOutlook.AppointmentCollection' to
'System.Data.DataTable'

can anyone tell me what i can do to hide or remove some rows from a
datagrid without affecting the underlying data records?

thanks
batterheadccw
 
P

Peter Foot [MVP]

If you just want to display a list of a specific subset with a complex query
in this way the best result is probably to filter as many as you can with
Restrict first as this passes the processing down to native code. Then with
the remaining items loop through the connection and add the fields you want
to hang on to to an arraylist or similar. So you may define a custom type
which has just the subject and ItemId of the appointment. Then when it's
selected you can get the full appointment details from the ItemId.

Peter
 
N

None

If you just want to display a list of a specific subset with a complex query
in this way the best result is probably to filter as many as you can with
Restrict first as this passes the processing down to native code. Then with
the remaining items loop through the connection and add the fields you want
to hang on to to an arraylist or similar. So you may define a custom type
which has just the subject and ItemId of the appointment. Then when it's
selected you can get the full appointment details from the ItemId.

Peter

thanks peter,

but what i am going for is not a master/detail list. i just got one
datagrid on screen showing appointments with multiple columns, e.g.
start time, subject, location, etc, just like an agenda. do you mean i
have to give up the datagrid, instead use some kind of list, e.g.
listbox, to populate the appointment details? or there is some other
way to further filter the "restricted" datagrid.

thanks
batterheadccw
 
P

Peter Foot [MVP]

Well you could create your own collection of Appointment items. Then you've
got the complete object to work with. You could just add them to an
ArrayList then use ToArray to return a strongly typed Appointment[] which
you can bind the datagrid to.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top