Home All Groups Group Topic Archive Search About

Problem with multiple forms

Author
1 Jun 2005 6:35 AM
pkruger
Hello,

My application makes use of multiple forms. The problem is that if one form
is loaded and shown, and I close this form to go back to the previous form,
the previous form is displayed, but sometimes the focus is returned to a
background app, and not the main app.

My code to show the next form:

Private Sub btnStock_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStock.Click
        Me.Hide()
        frmStockGUI.btnStockCreate.Select()
        frmStockGUI.ShowDialog()
        Me.Show()
        btnStock.Focus()
End Sub

I even set the focus to a button on the main form, but no luck :-(

Any ideas?

Kind regards,
Pieter Kruger

Author
1 Jun 2005 8:07 AM
Jan Hyde
"pkruger" <pkru***@discussions.microsoft.com>'s wild
thoughts were released on Tue, 31 May 2005 23:35:29 -0700
bearing the following fruit:

Show quoteHide quote
>Hello,
>
>My application makes use of multiple forms. The problem is that if one form
>is loaded and shown, and I close this form to go back to the previous form,
>the previous form is displayed, but sometimes the focus is returned to a
>background app, and not the main app.
>
>My code to show the next form:
>
>Private Sub btnStock_Click(ByVal sender As System.Object, ByVal e As
>System.EventArgs) Handles btnStock.Click
>        Me.Hide()
>        frmStockGUI.btnStockCreate.Select()
>        frmStockGUI.ShowDialog()
>        Me.Show()
>        btnStock.Focus()
>End Sub
>
>I even set the focus to a button on the main form, but no luck :-(
>
>Any ideas?
>

To Quote Rick

Almost everybody in this newsgroup is using VB6 or lower.
While you may get a stray answer to VB.NET (including VB2003
and VB2005 which has dropped .NET from its name) questions
here, you should ask them in newsgroups devoted exclusively
to .NET programming. Look for newsgroups with either the
word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups for
Visual Basic .NET related questions...

microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data

And these for more general .NET questions

microsoft.public.dotnet.general
microsoft.public.vsnet.general

Note: There are many other .NET newgroups (use the first
three "fields" from the last two as templates when searching
for them), but the above ones should get you started.


Jan Hyde (VB MVP)

--
As far as we know, our computer has never had an undetected error.

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
1 Jun 2005 10:37 AM
pkruger
Sorry, my mistake :-) Thank you for pointing me to the right group.

Kind regards,
Pieter

Show quoteHide quote
"Jan Hyde" wrote:

> "pkruger" <pkru***@discussions.microsoft.com>'s wild
> thoughts were released on Tue, 31 May 2005 23:35:29 -0700
> bearing the following fruit:
>
> >Hello,
> >
> >My application makes use of multiple forms. The problem is that if one form
> >is loaded and shown, and I close this form to go back to the previous form,
> >the previous form is displayed, but sometimes the focus is returned to a
> >background app, and not the main app.
> >
> >My code to show the next form:
> >
> >Private Sub btnStock_Click(ByVal sender As System.Object, ByVal e As
> >System.EventArgs) Handles btnStock.Click
> >        Me.Hide()
> >        frmStockGUI.btnStockCreate.Select()
> >        frmStockGUI.ShowDialog()
> >        Me.Show()
> >        btnStock.Focus()
> >End Sub
> >
> >I even set the focus to a button on the main form, but no luck :-(
> >
> >Any ideas?
> >
>
> To Quote Rick
>
> Almost everybody in this newsgroup is using VB6 or lower.
> While you may get a stray answer to VB.NET (including VB2003
> and VB2005 which has dropped .NET from its name) questions
> here, you should ask them in newsgroups devoted exclusively
> to .NET programming. Look for newsgroups with either the
> word "dotnet" or "vsnet" in their name.
>
> For the microsoft news server, try these newsgroups for
> Visual Basic .NET related questions...
>
> microsoft.public.dotnet.languages.vb
> microsoft.public.dotnet.languages.vb.upgrade
> microsoft.public.dotnet.languages.vb.controls
> microsoft.public.dotnet.languages.vb.data
>
> And these for more general .NET questions
>
> microsoft.public.dotnet.general
> microsoft.public.vsnet.general
>
> Note: There are many other .NET newgroups (use the first
> three "fields" from the last two as templates when searching
> for them), but the above ones should get you started.
>
>
> Jan Hyde (VB MVP)
>
> --
> As far as we know, our computer has never had an undetected error.
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>
>