xRuhRohx
xRuhRohx

Reputation: 422

Multiple instances of a predesigned form in VB

Visual Studio 2010, Visual Basic .NET

I have a form (frmImages) that opens when an image is clicked on inside a WebBrowser (wbContent) contorl on a form (frmContent).

I want the user to be able to click multiple images and open multiple instances of frmImages.


UPDATE Here is what I am working with now, am I heading in the right direction? This gives me the ability to open multiple instances but opens a duplicate. So for every image I click on, two identical forms open.

Dim images As New frmImages
If engineLine.IndexOf("\") <> -1 Then
    images.wbImages.Navigate(New Uri(engineLine & holdHTML))
Else
    images.wbImages.Navigate(New Uri(filePath & "IETMS\" & engineLine & "\" & engineLine & holdHTML))
End If

images.Text = ietmSelect & " - " & workPacket & " - " & removeTitleLinks(figTitle)
images.Show()

Upvotes: 0

Views: 85

Answers (2)

Dave Doknjas
Dave Doknjas

Reputation: 6542

Create all your form instances explicitly, especially when you want more than one instance of a form. In your example, you are creating one explicitly (frmImages2), but also using the VB default instance. VB allows you to use the name of the form class as a default instance, but this is a bad practice (and a bad feature - but VB is designed around making it easier for very junior programmers even if it makes it more confusing for all the rest).

Upvotes: 1

Steve
Steve

Reputation: 5545

You just need to create another instance of the form (NEW). Of coarse, your form cannot be modal or else they will never be able to access the parent form to click another image.

Dim x as new frmImages
x.show
x = new frmImages
x.show

Upvotes: 1

Related Questions