ExplorerBrowserControl でナビゲーションエリアを非表示にする - C#
概要
こちらの記事では、ExplorerBrowserControlを用いたファイルブラウザのコードを紹介しました。
実行結果は下図になりますが、利用シーンによっては左側のナビゲーションエリアを非表示にしたい場合があります。
この記事では、ナビゲーションエリアを非表示にするコードを紹介します。
コード
下記のコードを記述します。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Controls;
using Microsoft.WindowsAPICodePack.Shell;
namespace ExplorerDemo
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void FormMain_Shown(object sender, EventArgs e)
{
explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = PaneVisibilityState.Hide;
explorerBrowser1.Navigate((ShellObject)KnownFolders.Desktop);
}
}
}
解説
PanelVisibilityプロパティを変更することで、ナビゲーションエリアを非表示にできます。
explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = PaneVisibilityState.Hide;
実行結果
プロジェクトを実行します。下図のウィンドウが表示されます。ナビゲーションエリアが表示されていません。
パネル一覧
ExplorerBrowserで表示、非表示を切り替えられるパネルは以下があります。
パネル | 説明 |
AdvancedQuery | EP_AdvQueryPane "b4e9db8b-34ba-4c39-b5cc-16a1bd2c411c" に対応している |
Commands | 「新しいフォルダ」などのコマンドが表示されるツールバー |
CommandsOrganize | 「整理」メニューをCommandsツールバーに表示する。Commandsを表示する必要がある。 |
CommandsView | 「大アイコン」「詳細」「並べて表示」などの表示切替ボタンをCommandsツールバーに表示する。Commandsを表示する必要がある。 |
Details | システム情報、ファイル情報、画像プレビュー、画像サイズなどをを表示 |
Navigation | 左側に表示されるツリービュー |
Preview | プレビュー(右側に表示)、画像プレビューが表示される。 |
Query | EP_QueryPane "65bcde4f-4f07-4f27-83a7-1afca4df7ddd" に対応している。 |
補足
- DetailsパネルはWindows 7では下部に表示、Windows 8では右側に表示
- PreviewパネルはWindows 7,Windows 8ともに右側に表示
- Windows 8ではDetailsパネルとPreviewパネルは排他となり、両方を表示する場合はDetailsが優先される。
すべてのパネルを表示した状態
すべてのパネルを非表示した状態
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用