16,717
社区成员
发帖
与我相关
我的任务
分享' Copyright (c) Microsoft Corporation. All rights reserved.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class ExplorerStyleViewer
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.exitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SplitContainer1 = New System.Windows.Forms.SplitContainer
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip
Me.fileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SplitContainer1.SuspendLayout()
Me.MenuStrip1.SuspendLayout()
Me.SuspendLayout()
'
'exitToolStripMenuItem
'
Me.exitToolStripMenuItem.Name = "exitToolStripMenuItem"
Me.exitToolStripMenuItem.Text = "E&xit"
'
'SplitContainer1
'
Me.SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainer1.Location = New System.Drawing.Point(0, 24)
Me.SplitContainer1.Name = "SplitContainer1"
Me.SplitContainer1.Size = New System.Drawing.Size(688, 481)
Me.SplitContainer1.SplitterDistance = 230
Me.SplitContainer1.TabIndex = 10
'
'MenuStrip1
'
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.fileToolStripMenuItem})
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(688, 24)
Me.MenuStrip1.TabIndex = 9
Me.MenuStrip1.Text = "MenuStrip1"
'
'fileToolStripMenuItem
'
Me.fileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.exitToolStripMenuItem})
Me.fileToolStripMenuItem.Name = "fileToolStripMenuItem"
Me.fileToolStripMenuItem.Text = "&File"
'
'ExplorerStyleViewer
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(688, 505)
Me.Controls.Add(Me.SplitContainer1)
Me.Controls.Add(Me.MenuStrip1)
Me.MainMenuStrip = Me.MenuStrip1
Me.Name = "ExplorerStyleViewer"
Me.Text = "ExplorerStyleViewer2"
Me.SplitContainer1.ResumeLayout(False)
Me.MenuStrip1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents exitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SplitContainer1 As System.Windows.Forms.SplitContainer
Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
Friend WithEvents fileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
End Class
' Copyright (c) Microsoft Corporation. All rights reserved.
Imports System.IO
Public Class ExplorerStyleViewer
' Declare variables to hold instances of each of the custom classes
Private dtvwDirectory As DirectoryTreeView
Private flvFiles As FileListView
Private mivChecked As MenuItemView
' Handles the AfterSelect event for the DirectoryTreeView, which causes the
' FileListView object to display the contents of the selected directory.
Sub DirectoryTreeViewOnAfterSelect(ByVal obj As Object, ByVal tvea As TreeViewEventArgs)
flvFiles.ShowFiles(tvea.Node.FullPath)
End Sub
' This subroutine handles the Form Load event.
Private Sub ExplorerStyleViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create a flvFilesView instance.
flvFiles = New FileListView()
SplitContainer1.Panel2.Controls.Add(flvFiles)
flvFiles.Dock = DockStyle.Fill
' Create a DirectoryTreeView instance and add an OnAfterSelect event handler.
dtvwDirectory = New DirectoryTreeView()
'dtvwDirectory.Parent = Me
SplitContainer1.Panel1.Controls.Add(dtvwDirectory)
dtvwDirectory.Dock = DockStyle.Left
' Dynamically add an AfterSelect event handler.
AddHandler dtvwDirectory.AfterSelect, _
AddressOf DirectoryTreeViewOnAfterSelect
' Add a View menu command to the existing main menu.
Dim menuView As New ToolStripMenuItem("&View")
MenuStrip1.Items.Add(menuView)
' Add four menu items to the new View menu. Start by creating arrays to set
' properties of each menu item.
Dim astrView As String() = {"Lar&ge Icons", "S&mall Icons", "&List", "&Details"}
Dim aview As View() = {View.LargeIcon, View.SmallIcon, View.List, View.Details}
' Create an event handler for the menu items.
Dim eh As New EventHandler(AddressOf MenuOnViewSelect)
Dim i As Integer
For i = 0 To 3
' Use a custom class MenuItemView, which extends MenuItem to support a
' View property.
Dim miv As New MenuItemView()
miv.Text = astrView(i)
miv.View = aview(i)
miv.Checked = False
' Associate the handler created earlier with the Click event.
AddHandler miv.Click, eh
' Set the Default view to Details.
If i = 3 Then
mivChecked = miv
mivChecked.Checked = True
flvFiles.View = mivChecked.View
End If
' Add the new menu item to the View menu.
menuView.DropDownItems.Add(miv)
Next i
End Sub
' Handles the OnViewSelect event for the View menu items.
Sub MenuOnViewSelect(ByVal obj As Object, ByVal ea As EventArgs)
' Uncheck the currently checked item.
mivChecked.Checked = False
' Cast the event sender and check it.
mivChecked = CType(obj, MenuItemView)
mivChecked.Checked = True
' Change how the files are viewed in the FileListView control.
flvFiles.View = mivChecked.View
End Sub
Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click
Me.Close()
End Sub
End Class