Solved

form set focus vb.net

Posted on 2006-07-13
4
1,759 Views
Last Modified: 2012-08-13
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
Comment
Question by:jackjohnson44
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
tsay earned 400 total points
ID: 17099703
try this:

dim myTestForm as new FrmTestCommands
myTestForm.show()
me.focus
0
 
LVL 6

Assisted Solution

by:manch
manch earned 100 total points
ID: 17099716


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

Expert Comment

by:tsay
ID: 17099727
that's like EXACTLY what I told, but only you use 2 times the code...
0
 
LVL 2

Expert Comment

by:cwile
ID: 17099771
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now