nieyangjie

一个用缩略图作图标显示的例子

代码需要重新引用dll 文件

文件名称: ExpCombo_Demo.zip    ExpCombo_src.zip


    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.OpenFileDialog1.SaveState("C:\Settings.txt")
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler english.CheckedChanged, AddressOf Me.Language_CheckedChanged
        AddHandler german.CheckedChanged, AddressOf Me.Language_CheckedChanged
        AddHandler os.CheckedChanged, AddressOf Me.Language_CheckedChanged

        AddHandler allFolders.CheckedChanged, AddressOf Me.Style_CheckedChanged
        AddHandler currentFolder.CheckedChanged, AddressOf Me.Style_CheckedChanged

        subFoldersColumn.CustomGrouping = True

        SetColumnText()
    End Sub

    Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse.Click
        If Me.BrowseForFolder1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            MessageBox.Show(Me.BrowseForFolder1.SelectedPath)
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        Me.Browser1.AllowNewFolders = Me.CheckBox1.Checked
        Me.BrowseForFolder1.AllowNewFolders = Me.CheckBox1.Checked
        Me.OpenFileDialog1.AllowNewFolders = Me.CheckBox1.Checked
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        ExplorerControls.Sounds.Silent = Not CheckBox2.Checked
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim ds As New DataSet
            ds.ReadXml("C:\Settings.txt")
            Me.OpenFileDialog1.LoadState(ds, True)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        If Me.OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            MessageBox.Show(Me.OpenFileDialog1.FileName)
        End If
    End Sub

    Private Sub Language_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles german.CheckedChanged
        If english.Checked Then
            Me.Browser1.Language = ExplorerControls.Language.English
            Me.ExpList1.Language = ExplorerControls.Language.English
        ElseIf german.Checked Then
            Me.Browser1.Language = ExplorerControls.Language.Deutsch
            Me.ExpList1.Language = ExplorerControls.Language.Deutsch
        ElseIf os.Checked Then
            Me.Browser1.Language = ExplorerControls.Language.OperatingSystem
            Me.ExpList1.Language = ExplorerControls.Language.OperatingSystem
        End If
    End Sub

    Private Sub ExpList1_ItemsAdded(ByVal sender As Object, ByVal e As ExplorerControls.ExpList.ExpListItemsAddedEventArgs) Handles ExpList1.ItemsAdded
        Me.Cursor = Cursors.WaitCursor

        'Don't allow doubles
        Dim itm As ExplorerControls.ExpListItem
        Dim existingItems As New ArrayList
        Dim doubles As New ArrayList
        For Each itm In ExpList1.Items
            If existingItems.IndexOf(itm.CShItem.Path) > -1 Then
                doubles.Add(itm)
            End If
            existingItems.Add(itm.CShItem.Path)
        Next
        For Each itm In doubles
            ExpList1.Items.Remove(itm)
        Next

        'Add any files in a folder
        For Each itm In e.Items
            If itm.CShItem.IsFolder Then
                AddFilesFromFolder(itm.CShItem)
                ExpList1.Items.Remove(itm)
            End If
        Next
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub AddFilesFromFolder(ByVal folder As ExplorerControls.CShItem)
        If Not subFolders.Checked Then
            Dim fileList As New ArrayList
            fileList = folder.GetFiles()
            If fileList.Count > 0 Then
                fileList.Sort()
                ExpList1.Items.AddRange(CType(fileList.ToArray _
                    (GetType(ExplorerControls.CShItem)), ExplorerControls.CShItem()))
            End If
        Else
            ExpList1.FillExpList(folder, False)
        End If
    End Sub

    Private Sub Browser1_Group(ByVal sender As Object, ByVal e As ExplorerControls.ExpList.ExpListGroupEventArgs) Handles Browser1.Group
        If Not e.Column Is subFoldersColumn Then Exit Sub
        Dim itm As ExplorerControls.ExpListItem
        For Each itm In Browser1.ExpListItems
            Dim groupName As String
            If itm.CShItem.HasSubFolders Then
                groupName = "True (Custom Group)"
            Else
                groupName = "False (Custom Group)"
            End If
            If IsNothing(Browser1.ExpListGroups(groupName)) Then
                itm.Group = Browser1.ExpListGroups.Add(groupName, groupName)
            Else
                itm.Group = Browser1.ExpListGroups(groupName)
            End If
        Next
    End Sub

    'Use ItemsAdded to set the item text - SelectedFolderChanged won't work with refresh
    Private Sub Browser1_ItemsAdded(ByVal sender As Object, ByVal e As ExplorerControls.ExpList.ExpListItemsAddedEventArgs) Handles Browser1.ItemsAdded
        SetColumnText()
    End Sub

    'Private Sub Browser1_SelectedFolderChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Browser1.SelectedFolderChanged
    '    SetColumnText()
    'End Sub

    Private Sub SetColumnText()
        Dim itm As ExplorerControls.ExpListItem
        For Each itm In Browser1.ExpListItems
            Dim index As Integer = Browser1.Columns.IndexOf(subFoldersColumn)
            If index > -1 Then
                itm.SubItems(index).Text = CStr(itm.CShItem.HasSubFolders)
            End If
        Next
    End Sub

    Private Sub subFoldersColumn_ColumnAdded(ByVal sender As Object, ByVal e As System.EventArgs) Handles subFoldersColumn.ColumnAdded
        SetColumnText()
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        Me.Browser1.DisplayPath = CheckBox3.Checked
    End Sub

    Private Sub Style_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles allFolders.CheckedChanged
        If currentFolder.Checked Then
            Me.Browser1.Style = ExplorerControls.ExpComboStyle.CurrentFolder
        ElseIf allFolders.Checked Then
            Me.Browser1.Style = ExplorerControls.ExpComboStyle.AllFolders
        End If
    End Sub

 

posted on 2009-07-14 19:45  nieyangjie  阅读(422)  评论(0编辑  收藏  举报

导航