Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9112485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:44:48+00:00 2026-06-17T03:44:48+00:00

I have some problems with Form control focusing. On form1 I click a button

  • 0

I have some problems with Form control focusing.

On form1 I click a button and run the code below:

private void btnTest_Click(object sender, System.EventArgs e)
{
    form2 = new Form2();

    Application.Idle += new EventHandler(Application_Idle);

    form2.Show();
    form2.Activate();
    form2.textBox1.Focus();

    Form3 form3 = new Form3();
    form3.ShowDialog();
}

Then, after this CLR I run the event Application_Idle on which I add a method that must focus on the textBox2 control..

private void Application_Idle(object sender, EventArgs e)
{
    form2.textBox2.Focus();
    form2.textBox2.Select();
    form2.textBox2.Focus();

    Application.Idle -= new EventHandler(Application_Idle);
}

But when I click the button on form1, I see Form2 showing, Form3 showing and then Application_Idle method raise, but form2.textBox2 control doesn’t get focused…

If I comment out the form3.ShowDialog(); line it’s works fine, but how do I focus a form element with another form activation?(form3.ShowDialog()) ?

Remark added:
Problem in also is I have a strict architecture and all I can change is Application_Idle method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:44:49+00:00Added an answer on June 17, 2026 at 3:44 am

    The issue you are having is with modality:

    Forms and dialog boxes are either modal or modeless. A modal form or dialog box must be closed or hidden before you can continue working with the rest of the application.

    Dialog boxes that display important messages should always be modal. The About dialog box in Visual Studio is an example of a modal dialog box. MessageBox is a modal form you can use.

    Modeless forms let you shift the focus between the form and another form without having to close the initial form. The user can continue to work elsewhere in any application while the form is displayed.

    When you use ShowDialog, the form that is shown prevents the caller from returning control until the dialog box is closed. If this is not the desired effect, you can use the Show method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problems sending an id though jquery. I have a form select
I have some problems with the Form.AutoScaleMode property together with fixed size controls, when
I'm having some problems with a jQuery control we made. Suppose you have a
I have some code that does custom drawing. Basically it is form fill program
I am having some Problems with JavaScript. I have got the following code: <html>
I have to fix some problems and enchance form designer written long ago for
I seem to have a problem passing some strings on from one form to
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have some problems with Javascript. In fact, I'm just newbie in that script
I have some problems with header() function. It works and doesn't work at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.