OpenFileDialog와 Filter 사용법
*
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub
End Class

OpenFileDialog와 Filter 사용법

다른 Dialog에서의 Filter 사용법을 익혀보세여.

 

이 게시물을

댓글'2'
교교
  • 2014.02.28

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Filter = "Text File(*.txt)|*.txt|All File|*.*"
        OpenFileDialog1.Title = " OPEN File "
        OpenFileDialog1.InitialDirectory = "c:\"
        OpenFileDialog1.ShowDialog()

    End Sub


    Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        TextBox1.Text = OpenFileDialog1.FileName
    End Sub
End Class

이 댓글을

교교
  • 2014.02.28

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim myStream As Stream = Nothing Dim openFileDialog1 As New OpenFileDialog() openFileDialog1.InitialDirectory = "c:\" openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" openFileDialog1.FilterIndex = 2 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Try myStream = openFileDialog1.OpenFile() If (myStream IsNot Nothing) Then ' Insert code to read the stream here. End If Catch Ex As Exception MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message) Finally ' Check this again, since we need to make sure we didn't throw an exception on open. If (myStream IsNot Nothing) Then myStream.Close() End If End Try End If End Sub

이 댓글을

공유하기

SEARCH

MENU NAVIGATION