SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample illustrates implementation of a simple Windows Explorer/File Explorer.
The source code is located at C:\Program Files (x86)\Softelvdm\SftDirectory 3.0\Samples\Visual Studio - VB.NET\SimpleExplorer\Form1.vb or C:\Program Files\Softelvdm\SftDirectory 3.0\Samples\Visual Studio - VB.NET\SimpleExplorer\Form1.vb (on 32-bit Windows versions).
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' call this to update the buttons
UpdateLeftButtons()
UpdateRightButtons()
AxSftDirectoryRight.MakeColumnsOptimal()
End Sub
Private Sub AxSftDirectoryLeft_SelectionFinal(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftDirectoryLeft.SelectionFinal
' If the selection in the left tree changes, update right side detaillist
UpdateLeftButtons()
AxSftDirectoryRight.Clear()
AxSftDirectoryRight.CancelMode()
AxSftDirectoryRight.Refresh()
If Not AxSftDirectoryLeft.CurrentFolder Is Nothing Then
AxSftDirectoryRight.TopMostFolderIDL = AxSftDirectoryLeft.CurrentFolder.ItemIDList
Else
AxSftDirectoryRight.TopMostFolderSpecial = SftDirectorySpecialFolderConstants.specialSftDirectoryEmpty
End If
End Sub
Private Sub AxSftDirectoryRight_Opening(ByVal sender As Object, ByVal e As AxSftDirectoryLib30._ISftDirectoryEvents_OpeningEvent) Handles AxSftDirectoryRight.Opening
Dim F As SftDirectoryFolder
Dim IDL As String
' we're about to open a file/folder. If we can add the folder on the
' left side, that means we don't need to open it in a separate window
IDL = e.folder.ItemIDList ' the folder we are looking for
' this will add the complete hierarchy down to the folder in
' left tree (if possible)
On Error Resume Next
F = AxSftDirectoryLeft.get_FolderUsingIDL(IDL, False)
On Error GoTo 0
' this will locate the exact item if we just added it
F = AxSftDirectoryLeft.get_FolderUsingIDL(IDL, True)
If Not F Is Nothing Then
' The folder has been added on the left side
F.MakeCurrent() ' make it the current item
F.MakeVisible() ' make sure it's scrolled into view
e.allow = False ' no need to open it
End If
End Sub
Private Sub AxSftDirectoryRight_SelectionFinal(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftDirectoryRight.SelectionFinal
UpdateRightButtons()
If Not AxSftDirectoryRight.CurrentFolder Is Nothing Then
StatusBar.Text = AxSftDirectoryRight.CurrentFolder.InfoTip
Else
StatusBar.Text = ""
End If
End Sub
Private Sub UpdateLeftButtons()
' Update the buttons dependent on the left tree
Dim F As SftDirectoryFolder
' Enable/disable Up button
F = AxSftDirectoryLeft.CurrentFolder
If Not F Is Nothing Then
F = F.Parent
End If
ButtonUp.Enabled = Not F Is Nothing
End Sub
Private Sub UpdateRightButtons()
' Update the buttons dependent on the right side detaillist
Dim F As SftDirectoryFolder
' Enable/disable properties button
F = AxSftDirectoryRight.CurrentFolder
ButtonProp.Enabled = False
If AxSftDirectoryRight.SelectionCount > 0 And Not F Is Nothing Then
If F.Can("properties") Then
ButtonProp.Enabled = True
End If
End If
' Enable/disable New Folder button
ButtonNewFolder.Enabled = False
F = AxSftDirectoryRight.RootFolder
If Not F Is Nothing Then
If F.Can("NewFolder") Then
ButtonNewFolder.Enabled = True
End If
End If
End Sub
Private Sub ButtonUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUp.Click
' Move up on level in left side tree control
Dim F As SftDirectoryFolder
F = AxSftDirectoryLeft.CurrentFolder
If Not F Is Nothing Then
F = F.Parent
If Not F Is Nothing Then
F.MakeCurrent() ' make it the current item
F.MakeVisible() ' make sure it's scrolled into view
End If
End If
End Sub
Private Sub ButtonProp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonProp.Click
' Display properties dialog for the currently selected item
Dim F As SftDirectoryFolder
F = AxSftDirectoryRight.CurrentFolder
If AxSftDirectoryRight.SelectionCount > 0 And Not F Is Nothing Then
F.Do("properties")
End If
End Sub
Private Sub ButtonNewFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNewFolder.Click
' Create a new folder
Dim F As SftDirectoryFolder
F = AxSftDirectoryRight.RootFolder
If Not F Is Nothing Then
On Error Resume Next
F.Do("NewFolder")
End If
End Sub
Private Sub AxSftDirectoryLeft_KeyDownEvent(ByVal sender As Object, ByVal e As AxSftDirectoryLib30._ISftDirectoryEvents_KeyDownEvent) Handles AxSftDirectoryLeft.KeyDownEvent
' F5 automatically reloads left side, but we also want right side updated
If e.keyCode = Keys.F5 Then AxSftDirectoryRight.Reload(True, True)
End Sub
Private Sub AxSftDirectoryRight_KeyDownEvent(ByVal sender As Object, ByVal e As AxSftDirectoryLib30._ISftDirectoryEvents_KeyDownEvent) Handles AxSftDirectoryRight.KeyDownEvent
' F5 automatically reloads right side, but we also want left side updated
If e.keyCode = Keys.F5 Then AxSftDirectoryLeft.Reload(True, True)
End Sub
End Class