PC Review


Reply
Thread Tools Rate Thread

Dialoghie box problem

 
 
Poppy
Guest
Posts: n/a
 
      12th Dec 2003
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



 
Reply With Quote
 
 
 
 
Erik Vegting
Guest
Posts: n/a
 
      12th Dec 2003
Remove the first ofdImage1.ShowDialog() line.
Within the If() statement you open the dialog a second time!

Erik

"Poppy" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Peter van der Veen
Guest
Posts: n/a
 
      12th Dec 2003
I think if you remove the first showdialog if will work


On Fri, 12 Dec 2003 10:36:55 -0000, "Poppy"
<(E-Mail Removed)> wrote:

>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
>
>


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      12th Dec 2003
"Poppy" <(E-Mail Removed)> schrieb
> 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'd call Showdialog only once.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
Poppy
Guest
Posts: n/a
 
      12th Dec 2003
Thanks FOr Your Help.

I feel very silly now.


"Peter van der Veen" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> I think if you remove the first showdialog if will work
>
>
> On Fri, 12 Dec 2003 10:36:55 -0000, "Poppy"
> <(E-Mail Removed)> wrote:
>
> >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
> >
> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem after problem after problem - winXP wont start! =?Utf-8?B?TWF2aXJpY2s=?= Windows XP Help 2 23rd Apr 2006 02:55 PM
Problems With Adaptec 2400a RAID Card. (rare problem ? ? ? or Common Problem...? ? ?) Starz_Kid Computer Hardware 0 28th Dec 2005 05:36 AM
Microsoft Access Object Library Version Problem (Form VBA Code Problem) Don Microsoft Access Form Coding 2 8th Mar 2004 01:00 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Hardware 2 5th Feb 2004 10:22 PM
hibernation problem! problem!, Power Option problem! Farzad Hayati Microsoft Windows 2000 Advanced Server 2 5th Feb 2004 10:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.