in the below coding the files selected in the dialog box are dispalyed in the list-box, but while selecting the format i need to display only the selected format files to be displayed , how to modify the coding to keep like that.
Imports System.IO
Public Class Form1
Dim fdlg As OpenFileDialog = New OpenFileDialog()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
fdlg.Title = "open"
fdlg.InitialDirectory = "c:\"
fdlg.Filter = "document files(*.RTF)|*.RTF|document files(*.doc)|*.doc"
fdlg.FilterIndex = 1
fdlg.RestoreDirectory = True
If fdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Add(Path.GetFileName(fdlg.FileName))
'MessageBox.Show("You selected " & fdlg.FileName)
End If
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim item As Object = ListBox1.SelectedItem
If Not item Is Nothing Then
Dim index As Integer = ListBox1.Items.IndexOf(item)
If index < ListBox1.Items.Count - 1 Then
ListBox1.Items.RemoveAt(index)
index += 1
ListBox1.Items.Insert(index, item)
ListBox1.SelectedIndex = index
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim item As Object = ListBox1.SelectedItem
If Not item Is Nothing Then
Dim index As Integer = ListBox1.Items.IndexOf(item)
If index <> 0 Then
ListBox1.Items.RemoveAt(index)
index -= 1
ListBox1.Items.Insert(index, item)
ListBox1.SelectedIndex = index
End If
End If
End Sub
End Class