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.
 Sub SetupDocList()

     ' Assumes an instance of DocumentList,
     ' documentList1, has been declared.
     With DocumentList1
         .Parent = Me
         .Filter = " |*.*| |*.txt;*.xml| |*.pwi;*.pdt| " & _
             "|*.pxl;*.psw| |*.jpg;*.gif;*.bmp| |*.wav;*.wmv;*.mpg;"
         .FilterIndex = 0
         .SelectedDirectory = "Business"
     End With

 End Sub

' Handle the DocumentedActivated
' event with code to open the file.
 Private Sub DocList_DocumentActivated(ByVal sender As Object, _
     ByVal docevent As Microsoft.WindowsCE.Forms.DocumentListEventArgs) _
     Handles DocumentList1.DocumentActivated

     StatusBar1.Text = "Activated: " & docevent.Path
 ' Add code to open the selected file.

 End Sub

 ' Handle the DeletingDocument 
 ' event with code to close the file.
 Private Sub DocList_DeletingDocument(ByVal sender As Object, _
     ByVal docevent As Microsoft.WindowsCE.Forms.DocumentListEventArgs) _
     Handles DocumentList1.DeletingDocument

     StatusBar1.Text = "Deleted: " & docevent.Path
     ' Add code to close any instances of the file.

 End Sub

 ' Handle the SelectedDirectoryChanged
 ' event with code that sets the correct
 ' path for opening and closing files.
 Private Sub DocList_SelectedDirectoryChanged( _
     ByVal sender As Object,  ByVal e As System.EventArgs) _
     Handles DocumentList1.SelectedDirectoryChanged

     StatusBar1.Text = "Folder: " & DocumentList1.SelectedDirectory
     ' Add code to access the selected folder to open and close files.    

 End Sub


This example requires references to the following namespaces:

Show: