Tracking item within a collection on WP7 - vb.net

I'm building a WP7 (VB.NET) app and have a custom class, PinInfo, of which I have two ObservableCollections, TempPins and FavoritePins.
In various parts of the app, I need a unique identifier to get a reference to a particular PinInfo in the collection, so at present, I assign an ID to the PinInfo when it's added to the collection, then later get a reference to the pin via the ID.
For example, if I create a button to delete a pin, I set its tag to the pin's ID, then the button click handler reads the button's tag to get the corresponding pin from the collection (via LINQ).
I generate the ID by adding one to the last-assigned ID, but these lists are often modified (i.e. items removed), so I end up with needlessly large ID numbers (e.g. just a few items, with IDs in the thousands).
How can I structure this better?

You could use a Guid instead of an integer ID.

Related

How to display in Outlook, using VBA, a list of emails based on their EntryID (based on a list of EntryIDs stored in MS Access)

I have an Access DB that interacts with Outlook, including capturing the EntryID of selected emails as needed (which are stored in a table in Access)
I have code that allows users to view any email whose EntryID is stored, using Outlook's GetItemFromID method. This works as needed - it opens up a single email based on its EntryID.
However, what I am now looking to do is to filter the main Outlook window, to show emails based on a list of EntryIDs I have saved. So, for clarification, if I have a list of eg 3 emails (with their respective EntryIDs), the main Outlook window would be filtered to show those 3 emails. So basically like a search, but based on EntryIDs.
I can't seem to find anyway to do this? Perhaps there is a way to add a search filter via VBA that will search based on EntryIDs, but I can't find anything on this.
Any ideas much appreciated.
Binary properties like EntryID can't be used in any search or filtering operation in Outlook. You need to use any other properties (custom or user-defined ones) for filtering items in Outlook.
The View.Filter property value is a string, in DAV Searching and Locating (DASL) syntax, that represents the current filter for the view. For more information about using DASL syntax to filter items in a view, see Filtering Items.
Private Sub FilterViewToLastWeek()
Dim objView As View
' Obtain a View object reference to the current view.
Set objView = Application.ActiveExplorer.CurrentView
' Set a DASL filter string, using a DASL macro, to show
' only those items that were received last week.
objView.Filter = "%lastweek(""urn:schemas:httpmail:datereceived"")%"
' Save and apply the view.
objView.Save
objView.Apply
End Sub
Be aware, the EntryID value can be changed when items are moved between stores or folders. Moreover, the value is unique only per store.
If you need to show some items with specific EntryIDs strings you can get these item instances by using the GetItemFromID method and then marking them with a specific user property to be able to apply a filter for it. Or just add another string field to the Db with a custom value which can be added to items in Outlook, so you could easily apply a filter in the UI.

SharePoint 2010 SPD Workflow copy list item to new list and designate the content type

I have a functioning SPD workflow that copies the list item from list A to list B when the item in list A is marked approved.
My challenge is that list B has three content types to chose from. How do I designate which content type in list B to use when copying. I have a listbox that the user gets to choose what kind of a tool is being loaded. Some tools have required calibration dates and other tool specific items therefore the different content types.
I don't think you can specify the content type with Copy List Item - it should default to the default content type.
What I'd do instead is have my workflow Create List Item in List B, populating fields with values from Current Item. You can set Content Type ID by this process but it doesn't accept a variable, so use an If/Then block for each Tool type that only runs if that listbox value is selected.
Hope this helps!

Create an `Items` collection containing references to already existing `Item`s

I mean to create an Items collection, and add to it several already existing Items.
For instance, if I have two references to MailItems, I want to set an Items collection containing those two Items.
It would be something like
' ...
' Code that assigns references to olMail1 and olMail2, of type Outlook.MailItem
' ...
Dim MyItems As Outlook.Items
' Assign with Set / create the object
MyItems.Add olMail1
MyItems.Add olMail2
' Code that can use MyItems(1) to get a reference to olMail1
How can that be done?
Things to clarify are:
How to setup the new collection.
How to add items.
Documentation on Items.Add seems to indicate that it is used for adding newly created objects, not references to existing Items.
I would later iterate through that collection, for instance. I would also apply Find or Restrict; this allows for applying the methods on a much smaller collection than a whole Folder.
PS: I cannot get an Items collection even from
Application.ActiveExplorer.Selection (i.e., without need for creating the collection and add Items one by one). This would be good for a starter.
Background
I mean to find what Items have a sender matching a given string. The aspects that perhaps make my case somewhat more complex than a "base case" are:
I mean to apply the filter only on a selected group of items. E.g., only on the Items that are selected in the Inbox index.
I want to do partial matching. At this point I do not need regular expressions, or even full use of wildcards *?. But at least partial matching as in InStr.
I mean to have a specific Function for the minimal unit: testing one Item, for a single condition. Then loop through all target Items, and all conditions.
I conceived 3 approaches:
Use Rules.
Use Filter or Restrict. These do not accept wildcards (in principle?).
"Manually" check conditions, with InStr, e.g.
Each of the aspects above may bear some complexity for one or more of the approaches.
At this point, I was exploring approach 2. I have a reference to a single Item, and I found how to apply a Filter with a matching condition (see
http://www.outlookcode.com/news.aspx?id=30 ,
http://blogs.msdn.com/b/andrewdelin/archive/2005/05/11/416312.aspx , and the non-accepted answer of VBA Search in Outlook). But to apply the Filter, I need an Items collection, containing my single item.
I have something working with approach 3 (as suggested in the accepted answer of VBA Search in Outlook).
Related links
Identify MailItems satisfying a Rule
You can just use a regular collection:
Dim myItems As Collection
Set myItems = New Collection
myItems.Add olMail1
myItems.Add olMail2
Now if you're looking to restrict the type of objects than can be contained by myItems, then it becomes a bit more complicated, but here's a way to do it:
Restrict type in a Collection inside a class module
I'd suggest starting from the Getting Started with VBA in Outlook 2010 article in MSDN.
An instance of the Items class can't be created in the code. It is asociated and belongs to any folder. You can create a folder to get a new Items instance.
You can use the Copy method of Outlook items to create another instance of the object. Then the Move method can be used to move the item to another Items collection (folder).
1.I mean to apply the filter only on a selected group of items. E.g., only on the Items that are selected in the Inbox index.
You need to iterate over all selected items instead. The Find/FindNext and Restrict methods belong to the Items class only. So, you can apply them to the Folder items only.
2.I want to do partial matching. At this point I do not need regular expressions, or even full use of wildcards *?. But at least partial matching as in InStr.
See Filtering Items Using a String Comparison. You can use the ci_startswith or ci_phrasematch operators.
3.I mean to have a specific Function for the minimal unit: testing one Item, for a single condition. Then loop through all target Items, and all conditions.
Take a look at the Filtering Items section in MSDN which describes the general rules for specifying properties in filters that are supported by various objects in Outlook.
The Filter method of the View class is applied to the Outlook view only. The Items property will return the full list of items.
It would be better if you specify the final goal, not possible way to solve the problem which is not clear for us.

How to get dynamic created table's total column and row using Request.Form in vb.net

I am doing my project in Vb.net using MVC 4.0
I have created dynamic table and in that textboxes in td using javascript and now i want to get that table's total row and column as well for further process in Controller function.
How I can get using above using VB.net?
I have used Request.Form but the id of the textboxes in table is created uniquely so first I want to find the total column and row so based on that I can move further and check using for loop.
It seems like if you are generating your table through javascript you should also be able to set the value of a hidden field to the value you are outputting to your totals column. If you created a hidden field with the value set you should be able to access it from the Request collection. If it is not actually in a field that gets posted back you will only be able to access the value from the client-side.
document.getElementById("myInput").value = "Value you are outputting to your "total" cell
[Solved]
I got all the controls on code behind by it's name by using FormCollection just i need to do is post back the form using form action method because with using ajax i am not getting the formcollection in code behind but directly using form action method i can get all the controls name.
These are the textbox ids by which i can get the value just need to do further process like:
For Each _formvalues As String In formcol
formcol(_formvalues)
Next
fomcol is an object of FormCollection,_formvalues is used for moving one by one name coming in formcol and to take the data inside means name just write formcol(_formvalues) that's it.

Syntax for SharePoint 2010 BCS URL Action to populate New form

Have seen several posts with solutions for native SharePoint lists, including the very useful SPUtility.js (only for native SharePoint lists). But nothing to pass a value from a BCS list to a new BCS list. The Query string filter will not connect on the New form (no web part to connect it to) and does me no good on the lists page (already have that working).
A "go write custom code for everything" is not a solution for me.
There should be a way to 1) pass the value in the URL (ideal - what's the syntax?) or 2) make some other simple change, perhaps to the select list for the item -- I just can't find it. Have seen quite a few posts with similar questions. The Microsoft documentation is not useful and there are more questions on the "social" topics than answers.
Here's what I have:
I have a BCS list (sends item) tied to a BCS related list (receives item).
I have an action on the related list (ECT) to create a new item. Works fine with no parameters. I get a blank new form. The new form allows me to enter two items and choose two items (exactly as intended).
What I would like to have is the necessary ?something=something string so that my user does not have to select one of the choice items (MNumber - set as a key / required value)
User selects "New" from Actions.
Form Opens
MNumber is automatically filled in based on the MNumber of the current item displayed in the BCS related list.
The string I supply is accepted. Does nothing.
/intake/Lists/ContactsList/NewForm.aspx
/intake/Lists/ContactsList/NewForm.aspx?MNumber=1234
The string I supply is rejected - cannot be saved or insufficient values.
/intake/Lists/ContactsList/NewForm.aspx?MHICNumber={$MHICNumber}
Have also tried passing a string to one of the text fields (instead of the select field). Can't get that to work either. I've spent quite a few hours with the various boards. Nothing helpful.
Would also be nicer if I could set the New form to display in a pop-over window (as it does when I select New from the list view). Opening a new browser window is hokey and replacing the existing one is a navigation pain for the user.
Have this working ... Thanks to Kit Menke!
Created an Action on the External Content Type in the BCS....
/intake/Lists/ContactsList/NewForm.aspx?IDnumber={0}&Source=/intake/scheduling.aspx
where
parameter property 0 is the IDNumber from the ECT
The NewForm.aspx was edited to add a hidden content editor web part with references to three scripts Kit wrote - two supporting and one that sets the values.
http://site/list/NewForm.aspx?toolpaneview=2
User selects the Action on the displayed ECT list
Action uses the URL to go to the New page with the data
Kit's script adds the data to the form and puts in the date and time.
Note: The ID field needs to be a text field. Cannot be a selection list.