|
|
|
| フォームは、UserControl を使っています。フォーム上にドライブ選択用の ComboBox(CB1) と フォルダ選択用の TreeView(TV1) を配置します。さらに ImageList(IL1) を配置してお好みのアイコンを追加します。アイコンはVB付属のもので十分だと思います。 各コントロールのデフォルト値以外のプロパティは次の様に設定しています。 CB1 ... ContextMenu : PUP1 ... DrawMode : OwnerDrawFixed ... ItemHeight : 15 ... Dock : Top ... DrapDownStyle : DropDownList TV1 ... ContextMenu : PUP1 ... ImageList : IL1 ... Dock : Fill |
|
| PUP1 (MenuItem) ... mnOpen : フォルダを開く(&O) ... mnUpdate : 更新(&U) ... mnMakeFolder : フォルダの作成(&M) ... mnDeleteFolder : フォルダの削除(&D) ... mnRename : 名前の編集(&N) (セパレータは省略) |
| IL1 ... ImageSize : 16, 16 ... ColorDepth : Depth8Bit (左図のように Images プロパティに追加) |
Public Class DriveItem
Inherits System.Object
' 内部変数
Private m_name As String = "" ' ドライブ名
Private m_volume As String = "" ' ボリュームラベル
Private m_imageindex As Integer = 0 ' イメージの番号
' プロパティ : ドライブ名
Public Property Name() As String
Get
Return m_name
End Get
Set(ByVal Value As String)
m_name = Value
End Set
End Property
' プロパティ : ボリュームラベル
Public Property Volume() As String
Get
Return m_volume
End Get
Set(ByVal Value As String)
m_volume = Value
End Set
End Property
' プロパティ : イメージの番号
Public Property ImageIndex() As Integer
Get
Return m_imageindex
End Get
Set(ByVal Value As Integer)
m_imageindex = Value
End Set
End Property
' コンストラクタ
Public Sub New()
End Sub
' コンストラクタ (プロパティ値指定)
Public Sub New(ByVal name As String, _
ByVal volume As String, _
ByVal imageindex As Integer)
m_name = name
m_volume = volume
m_imageindex = imageindex
End Sub
End Class
Public Class PathNode
Inherits System.Windows.Forms.TreeNode
' 内部変数
Private m_folderpath As String = "" ' パス名
Private m_isvested As Boolean = False ' 子ノードを展開したかどうか
' プロパティ : パス名
Public Property FolderPath() As String
Get
Return m_folderpath
End Get
Set(ByVal Value As String)
m_folderpath = Value
End Set
End Property
' プロパティ : 子ノードを展開したかどうか
Public Property IsVested() As Boolean
Get
Return m_isvested
End Get
Set(ByVal Value As Boolean)
m_isvested = Value
End Set
End Property
' コンストラクタ(パス名を指定)
Public Sub New(ByVal path As String)
MyBase.New()
m_folderpath = path
Me.Text = System.IO.Path.GetFileNameWithoutExtension(path)
End Sub
' コンストラクタ(パス名と表示イメージのインデックスを指定)
Public Sub New(ByVal path As String, ByVal image1 As Integer, ByVal image2 As Integer)
MyBase.New()
m_folderpath = path ' パス名
Me.Text = System.IO.Path.GetFileNameWithoutExtension(path) ' 表示テキスト
Me.ImageIndex = image1 ' 通常のイメージのインデックス
Me.SelectedImageIndex = image2 ' 選択時のイメージのインデックス
End Sub
End Class