Link to home
Start Free TrialLog in
Avatar of James St. John
James St. JohnFlag for United States of America

asked on

How do I add a custom column to a SharePoint Document Library View

First things first... I'm a SharePoint novice.

I want to create a view in a SharePoint document library that includes a thumbnail view of the documents (doc, xls, pdf, etc).
None (repeat NONE) of the documents in the library will be picture files (jpeg, png, gif, etc.)

I have already written a DLL that implements the IShellFolder interface that creates the thumbnails at any size desired.

How do I create a view against a document library where I can programmatically add the column to the view, then create the thumbnail image (bitmap) from the document and insert it in the proper row/column in the view??  I figure I'd check to see if the thumbnail of the document has been cached (I am going to put them in the _t subfolder of the document folder), create (or update) the thumbnail if necessary, then retrieve the thumbnail image for use in the view.  I've seen numerous examples of SharePoint code, but none that work against a user defined view in a document library.

Thanks in advance
-- Jim
Avatar of HetAlps
HetAlps
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of quihong
quihong
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James St. John

ASKER

quihong:

Your comment was ***EXTREMELY*** helpful!!  It tells me I'm pointed in the right direction!!!

I created the "ThubnailImage" picture column (on a site level basis), and modified the site's document content type by adding the new column to it.

The problem I'm having is that I can't figure out how to update the field in the SPFile object.  The SPFile object doesn't expose a Fields collection, but the SPListItem
object associated the the SPFile object does.

I am iterating through the document libraries, getting access to each SPFile object within.  

foreach (SPFile myFile in myDocumentLibrary.Files)
{
   myFile.Item.Fields["ThumbnailImage"] = urlToImageFile;
   myFile.Update();
}

The statement

myFile.Item.Fields["ThumbnailImage"] = urlToImageFile;

is flagged as an error by the compiler -- Property or indexer 'Microsoft.SharePoint.SPFieldCollection.this[string]' cannot be assigned to -- it is read only

So, I've got the reference to the SPFile object, and I can get at the associated SPListItem object, but how the heck do I update the field?

Thanks again,
-- Jim
I am not an expert on the SharePoint Object Model, but I don't think you suppose to use the SPFile obkect. The SPListItem sounds right though