9/28/2011

VB.Net : Button DaialogBox Select File

Code
First you add ToolBox openfileDialog and set name.
example name is OpenFileDialog

Insert code in Button Click.
  1.    Private Sub Button_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Browse.Click
  2.         Dim PicturePath As String
  3.         OpenFileDialog.InitialDirectory = "C:\"
  4.         OpenFileDialog.Title = "Select Image File"
  5.         OpenFileDialog.Filter = "ไฟล์ภาพ (*.jpg;*.gif;*.bmp)|*.jpg;*.gif;*.bmp"
  6.         OpenFileDialog.ShowDialog()
  7.  
  8.         PicturePath = OpenFileDialog.FileName
  9.         'If Trim(PicturePath) = "" Or Len(PicturePath) = 0 Then Exit Sub
  10.         TextBox_URL.Text = PicturePath
  11.         'ให้ image1 แสดงผลภาพ
  12.         'Image1.Picture = LoadPicture(PicturePath)
  13.         Button_Clear.Enabled = True
  14.     End Sub

No comments:

Post a Comment