更新:2007 年 11 月
如果您的应用程序是基于文件处理的,则可以使用 DocumentList 控件来显示 My Documents 文件夹中的文件夹和文件的自定义列表。这与 Microsoft Pocket Word 和 Microsoft Pocket Excel 的运行方式相似。该控件为用户提供下面的功能:
- 选择、删除、复制、移动和重命名文件及文件夹。 
- 根据文件名、日期或大小进行排序。 
- 将文件作为电子邮件的附件发送。 
- 通过与另一设备的红外连接发送文件。 
实现 DocumentList 控件
- 使用 DocumentList 创建一个 Pocket PC Windows 应用程序。 
- 使用 Filter 属性指定可以访问的文件类型。 
- 使用 FilterIndex 属性指定最初显示的文件。 
- 使用 SelectedDirectory 属性指定一个默认文件夹。 
- 提供代码以处理 DocumentActivated 事件。 
- 提供代码以处理 DeletingDocument 事件。 
- 提供代码以处理 SelectedDirectoryChanged 事件。 
示例
此示例将 DocumentList 控件的 Parent 属性设置为窗体,使其占用该窗体的整个工作区。如果要使该控件占用较小的区域,则可以将其放置在一个 Panel 中,并指定长度。DocumentList 的宽度应为窗体的宽度。
 ' 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
// 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.
 }
编译代码
此示例需要引用下面的命名空间: