|
-
Dec 12th, 2003, 05:35 AM
#1
Thread Starter
Fanatic Member
Open File Dialogue problem
I use the following code to open a dialogue box. The user chooses a file and that image file is used as the source for the picturebox control :
Private Sub btnChoose1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose1.Click
Dim ofdImage1 As New OpenFileDialog()
ofdImage1.Filter = "Picture Files|*.bmp;*.jpg;*.jpeg;*.gif;*.ico"
ofdImage1.ShowDialog()
If (ofdImage1.ShowDialog() = DialogResult.OK) Then
Me.picImage1.Image = New Bitmap(ofdImage1.FileName)
End If
End Sub
The problem is that if I choose from the file dialogue box, or hit cancel, the dialogue box appears a second time.
I dont understand.
Any ideas folks ?
TIA
-
Dec 12th, 2003, 07:18 AM
#2
Sleep mode
remove this call ofdImage1.ShowDialog() and it should work as you want .
-
Dec 12th, 2003, 07:58 AM
#3
Addicted Member
Try this
VB Code:
Private Sub btnChoose1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose1.Click
Dim ofdImage1 As New OpenFileDialog()
ofdImage1.Filter = "Picture Files|*.bmp;*.jpg;*.jpeg;*.gif;*.ico"
If (ofdImage1.ShowDialog() = DialogResult.OK) Then
Me.picImage1.Image = New Bitmap(ofdImage1.FileName)
End If
End Sub
See you,
-Jai
[Friends Never Say Good Bye]
-
Dec 12th, 2003, 08:04 AM
#4
Sleep mode
Originally posted by Jaiboy
Try this
VB Code:
Private Sub btnChoose1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose1.Click
Dim ofdImage1 As New OpenFileDialog()
ofdImage1.Filter = "Picture Files|*.bmp;*.jpg;*.jpeg;*.gif;*.ico"
If (ofdImage1.ShowDialog() = DialogResult.OK) Then
Me.picImage1.Image = New Bitmap(ofdImage1.FileName)
End If
End Sub
lol , this is exactly what I said .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|