Condividi tramite


Classe DocumentList

Aggiornamento: novembre 2007

Rappresenta un controllo di Pocket PC per la visualizzazione e la gestione dei documenti in modo coerente.

Spazio dei nomi:  Microsoft.WindowsCE.Forms
Assembly:  Microsoft.WindowsCE.Forms (in Microsoft.WindowsCE.Forms.dll)

Sintassi

'Dichiarazione
Public Class DocumentList _
    Inherits Control
'Utilizzo
Dim instance As DocumentList
public class DocumentList : Control
public ref class DocumentList : public Control
public class DocumentList extends Control

Note

Il controllo DocumentList fornisce un'implementazione gestita del controllo DocList di Windows CE nativo, il controllo che è visibile, ad esempio, all'avvio di Microsoft® Pocket Word e Microsoft® Pocket Excel. Questo controllo fornisce la seguente funzionalità:

  • Selezione, eliminazione, copia, spostamento e ridenominazione di file e cartelle.

  • Ordinamento in base al nome, alla data o alle dimensioni dei file.

  • Invio di file per posta elettronica.

  • Invio di file tramite infrarossi a un altro dispositivo.

DocumentList è un controllo e non una finestra di dialogo quale FileDialog. L'utilizzo di un controllo DocumentList consente di includere menu personalizzati o altri controlli nell'interfaccia utente per la selezione dei file.

La larghezza del controllo DocumentList deve essere uguale a quella del modulo in cui viene collocato. Non vi sono limiti per la lunghezza, che può variare in base alle necessità.

Il controllo DocumentList visualizza solo i file di una cartella selezionata nella gerarchia della cartella Documenti.

Topic Location
Procedura: utilizzare un controllo DocumentList .NET Compact Framework
Procedura: utilizzare un controllo DocumentList .NET Compact Framework
Procedura: utilizzare un controllo DocumentList .NET Compact Framework

Esempi

Nell'esempio di codice riportato di seguito viene creato un controllo DocumentList contenuto in un oggetto Panel.

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());
    }
}

Gerarchia di ereditarietà

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

Codice thread safe

Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme

Windows Mobile per Pocket PC

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Compact Framework

Supportato in: 3.5, 2.0

Vedere anche

Riferimenti

Membri DocumentList

Spazio dei nomi Microsoft.WindowsCE.Forms

Altre risorse

Procedura: utilizzare un controllo DocumentList