How to: Use a DocumentList Control

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

If your application is based on working with files, you can use a DocumentList control to display a customized list of folders and files in the My Documents folder. This is similar to how Microsoft Pocket Word and Microsoft Pocket Excel operate. The control provides the user with the following functionality:

  • Select, delete, copy, move, and rename files and folders.

  • Sort by file name, date, or size.

  • Send files as e-mail attachments.

  • Send files by infrared to another device.

To implement a DocumentList control

  1. Create a Pocket PC Windows application with a DocumentList.

  2. Specify the file types that can be accessed with the Filter property.

  3. Specify the files that are initially displayed with the FilterIndex property.

  4. Specify a default folder with the SelectedDirectory property.

  5. Provide code to handle the DocumentActivated event.

  6. Provide code to handle the DeletingDocument event.

  7. Provide code to handle the SelectedDirectoryChanged event.

This example sets the Parent property for the DocumentList control to the form, making it occupy the entire client area of the form. If you want it to occupy a smaller area, you can place it in a Panel and specify the length. The width of a DocumentList should be the width of the form.

// Set up file extension filters for a
// DocumentList and set the initial folder
// to the Busines folder under My Documents.
 private void SetupDocList()

     // Assumes an instance of DocumentList,
     // documentList1, has been declared.
     documentList1.Parent = this;

     // Create event handlers for DocumentList events.
     documentList1.DocumentActivated +=
         new DocumentListEventHandler(this.OnDocActivated);

     documentList1.SelectedDirectoryChanged +=
         new EventHandler(this.OnFolderSel);

     documentList1.DeletingDocument +=
         new DocumentListEventHandler(this.OnDelDoc);

     documentList1.Filter = " |*.*| |*.txt;*.xml| |*.pwi;*.pdt| " +
         "|*.pxl;*.psw| |*.jpg;*.gif;*.bmp| |*.wav;*.wmv;*.mpg;";
     documentList1.FilterIndex = 0;
     documentList1.SelectedDirectory = "Business";

 private void OnDelDoc(object obj, DocumentListEventArgs DocArgs)
     statusBar1.Text += "Deleted: " + DocArgs.Path;

     // Add code to close any instances of the file.

 private void OnDocActivated(object obj, DocumentListEventArgs DocArgs)
     statusBar1.Text = "Activated: " + DocArgs.Path;

     // Add code to open the selected file.
 private void OnFolderSel(object obj, EventArgs eventg)
     statusBar1.Text = "Folder: " + documentList1.SelectedDirectory;

     // Add code to access the selected folder to open and close files.

This example requires references to the following namespaces: