方法 : DocumentList コントロールを使用します。

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

アプリケーションがファイルを扱うに基づく場合、DocumentList コントロールを使用して、マイ ドキュメント フォルダーにフォルダーとファイルのカスタマイズした一覧を表示することができます。 これは、Pocket Word および Pocket Excel の動作方法に似ています。 コントロールは、ユーザー、次の機能に提供します。

  • ファイルおよびフォルダーの選択、削除、コピー、移動、および名前の変更を行います。

  • ファイル名、日付、またはサイズで並べ替えます。

  • ファイルを電子メールの添付ファイルとして送信します。

  • 赤外線によって別のデバイスにファイルを送信します。

DocumentList コントロールを実装するには

  1. Pocket PC の Windows アプリケーションを DocumentList で作成します。

  2. Filter プロパティを使用してアクセスできるファイルの種類を指定します。

  3. FilterIndex プロパティで最初に表示されているファイルを指定します。

  4. SelectedDirectory プロパティを使用する既定のフォルダーを指定します。

  5. DocumentActivated イベントを処理するコードを提供します。

  6. DeletingDocument イベントを処理するコードを提供します。

  7. SelectedDirectoryChanged イベントを処理するコードを提供します。

使用例

次の使用例は、フォームの全体のクライアント領域を占有するので、フォーム、Parent コントロール/"、 DocumentList プロパティを設定します。 小さな領域を占有する場合は、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"EndWithEndSub
' Handle the DocumentedActivated' event with code to open the file.PrivateSub DocList_DocumentActivated(ByVal sender AsObject, _
     ByVal docevent As Microsoft.WindowsCE.Forms.DocumentListEventArgs) _
     Handles DocumentList1.DocumentActivated

     StatusBar1.Text = "Activated: " & docevent.Path
 ' Add code to open the selected file.EndSub
 ' Handle the DeletingDocument  ' event with code to close the file.PrivateSub DocList_DeletingDocument(ByVal sender AsObject, _
     ByVal docevent As Microsoft.WindowsCE.Forms.DocumentListEventArgs) _
     Handles DocumentList1.DeletingDocument

     StatusBar1.Text = "Deleted: " & docevent.Path
     ' Add code to close any instances of the file.EndSub
 ' Handle the SelectedDirectoryChanged ' event with code that sets the correct ' path for opening and closing files.PrivateSub DocList_SelectedDirectoryChanged( _
     ByVal sender AsObject,  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.    EndSub
                        // 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";
 }

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

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

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

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

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

コードのコンパイル方法

この例では、次の名前空間への参照が必要です。

参照

参照

DocumentList

その他の技術情報

Pocket PC の開発と、.NET Framework を最適化します。