DocumentList 类

表示以一致的方式显示和管理文档的 Pocket PC 控件。

命名空间:  Microsoft.WindowsCE.Forms
程序集:  Microsoft.WindowsCE.Forms(在 Microsoft.WindowsCE.Forms.dll 中)

语法

声明
Public Class DocumentList _
    Inherits Control
用法
Dim instance As DocumentList
public class DocumentList : Control
public ref class DocumentList : public Control
public class DocumentList extends Control

备注

DocumentList 控件提供本机 Windows CE DocList 控件的托管实现,此控件在某些情况下(例如,在启动 Microsoft® Pocket Word 和 Microsoft® Pocket Excel 时)是可见的。此控件提供以下功能:

  • 选择、删除、复制、移动和重命名文件和文件夹。

  • 按文件名、日期或大小排序。

  • 以电子邮件方式发送文件。

  • 通过红外装置将文件发送到其他设备。

DocumentList 是一个控件,而不是一个完整的类似于 FileDialog 的对话框。利用 DocumentList 控件,您可以在您的文件选择 UI 中加入自定义菜单或其他控件。

DocumentList 的宽度应与它所在的表单相同。长度可根据需要来决定。

DocumentList 仅显示“我的文档”层次结构中的所选文件夹的文件。

Topic Location
如何:使用 DocumentList 控件 .NET Compact Framework
如何:使用 DocumentList 控件 .NET Compact Framework
如何:使用 DocumentList 控件 .NET Compact Framework

示例

下面的代码示例创建 Panel 中包含的 DocumentList 控件。

Imports System
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports Microsoft.WindowsCE.Forms


Public Class Form1
   Inherits System.Windows.Forms.Form
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents DocumentList1 As Microsoft.WindowsCE.Forms.DocumentList

  Public Shared Sub Main()
    Application.Run(New Form1)
 End Sub

   Public Sub New()

      InitializeComponent()
      Me.MinimizeBox = false
      Me.DocumentList1 = New DocumentList

   'Set up file extension filters for a
   'DocumentList and set the initial folder
   'to the Busines folder under My Documents.
    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 


   Protected Overrides Sub Dispose(disposing As Boolean)
      MyBase.Dispose(disposing)
   End Sub 

   Private Sub InitializeComponent()
      Me.SuspendLayout()
        Me.StatusBar1 = New System.Windows.Forms.StatusBar
        '
        'StatusBar1
        '
        Me.StatusBar1.Location = New System.Drawing.Point(0,248)
        Me.StatusBar1.Size = New System.Drawing.Size(240,22)
        '
       '
      Me.Controls.Add(Me.StatusBar1)
      Me.Text = "DocList Demo"
      Me.ResumeLayout(False)
   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 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 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
End Class 
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;

public class Form1 : Form
{
    private DocumentList DocList;
    private StatusBar statusBar1;

    public Form1()
    {
        // Create an instance of a DocumentList control.
        DocList = new DocumentList();

        // Create an instance of the event handler delegate
        // using a reference to the OnDocActivated method,
        // which handles the DocumentActivated event.
        // Add the delegate instance to the DocumentActivated event.
        DocList.DocumentActivated +=
           new DocumentListEventHandler(this.OnDocActivated);

        // Create an instance of the event handler delegate
        // using a reference to the OnFolderSel method,
        // which handles the SelectedDirectoryChanged event.
        // Add the delegate instance to the
        // SelectedDirectoryChanged event.
        DocList.SelectedDirectoryChanged +=
           new EventHandler(this.OnFolderSel);

        // Create an instance of the event handler delegate
        // using a reference to the OnDelDoc method,
        // which handles the DeletingDocument event.
        // Add the delegate instance to the
        // DeletingDocument event.
        DocList.DeletingDocument +=
           new DocumentListEventHandler(this.OnDelDoc);

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

        statusBar1 = new StatusBar();
        statusBar1.Parent = this;
        DocList.Parent = this;
        this.Text = "DocList Demo";

        // Display the OK button for closing the application.
        this.MinimizeBox = false;
    }
    private void OnDelDoc(object obj, DocumentListEventArgs docg)
    {
        statusBar1.Text += "Deleted: " + docg.Path;

        // Add code to close any instances of the file.
    }
    private void OnDocActivated(object obj, DocumentListEventArgs docg)
    {
        statusBar1.Text = "Activated: " + docg.Path;

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

        // Add code to access the selected folder to open and close files.
    }
    static void Main()
    {
        Application.Run(new Form1());
    }
}

继承层次结构

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.Control
        Microsoft.WindowsCE.Forms.DocumentList

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Mobile for Pocket PC

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Compact Framework

受以下版本支持:3.5、2.0

另请参见

参考

DocumentList 成员

Microsoft.WindowsCE.Forms 命名空间

其他资源

如何:使用 DocumentList 控件