Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1782
  • Last Modified:

form set focus vb.net

In vb6 I would open a form, then set focus back to the form I was on, so the new form would be in the background.

how do I do this in vb.net?

        FrmTestCommands.Show()
        FrmMain.SetFocus()
0
jackjohnson44
Asked:
jackjohnson44
  • 2
2 Solutions
 
tsayCommented:
try this:

dim myTestForm as new FrmTestCommands
myTestForm.show()
me.focus
0
 
manchCommented:


U can write

   'Create the object for the form u want to show
    Dim objFrmTestCommands as FrmTestCommands

   'Instantiate the Object
    objFrmTestCommands = New FrmTestCommands
    'show the form u wanted
    objFrmTestCommands.Show()
    'and Then set the focus to the Main Form by the statement
    FrmMain.focus()
0
 
tsayCommented:
that's like EXACTLY what I told, but only you use 2 times the code...
0
 
cwileCommented:
This is a pretty dirty way, but it works


    Dim frm2 As New Form2
    Dim frm1 As New Form1

    frm2.Show()
    frm2.SendToBack()
    frm1.Show()
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now