I set the current directory so the FileListBox would look in one specific
path. It is the only method I could think to accomplish that part of this
project.
I know what you mean about the FileListBox, but it was just too tempting not
to use on this project.
I appreciate your pointers. I actually happened across another solution on
the web after posting this today. If you were interested here is a copy of
my final version.
Thanks for your help...
'*****************************************************************************************
'*****************************************************************************************
'*****************************************************************************************
Imports System.Diagnostics
Public Class Form1
Inherits System.Windows.Forms.Form
Dim myPath As String = "C:\WINEASY\ALL FMTS"
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
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.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents FileListBox1 As
Microsoft.VisualBasic.Compatibility.VB6.FileListBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.FileListBox1 = New Microsoft.VisualBasic.Compatibility.VB6.FileListBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Button1.Location = New System.Drawing.Point(328, 192)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(144, 56)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Open Label"
'
'FileListBox1
'
Me.FileListBox1.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.FileListBox1.Location = New System.Drawing.Point(40, 48)
Me.FileListBox1.Name = "FileListBox1"
Me.FileListBox1.Pattern = "*.fmt"
Me.FileListBox1.Size = New System.Drawing.Size(168, 251)
Me.FileListBox1.TabIndex = 3
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label1.Location = New System.Drawing.Point(256, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(288, 112)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Select the desired label in the list and then select the
Open Label button."
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.Label2.Location = New System.Drawing.Point(320, 280)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(232, 24)
Me.Label2.TabIndex = 5
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.TextBox1.Location = New System.Drawing.Point(40, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(168, 20)
Me.TextBox1.TabIndex = 6
Me.TextBox1.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(584, 326)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1,
Me.Label2, Me.Label1, Me.FileListBox1, Me.Button1})
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "WinEasy Label Launcher"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
System.IO.Directory.SetCurrentDirectory(myPath)
FileListBox1.Path = myPath
TextBox1.Select()
End Sub
Private Sub FileFileListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
FileListBox1.SelectedIndexChanged
Label2.Text = myPath & "\" & FileListBox1.FileName
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Process.Start(Label2.Text)
End Sub
Private Sub FileFileListBox1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles FileListBox1.DoubleClick
Process.Start(Label2.Text)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = "" Then Exit Sub
Dim listLength As Integer = (FileListBox1.Items.Count - 1)
Dim i, j As Integer
Dim listString, newString As String
For i = 0 To listLength
listString = FileListBox1.Items.Item(i)
If InStr(listString.ToLower, TextBox1.Text.ToLower) Then
FileListBox1.SetSelected(i, True)
End If
Next
listString = Nothing
newString = Nothing
listString = Nothing
End Sub
End Class
'*****************************************************************************************
'*****************************************************************************************
'*****************************************************************************************