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

  • SEARCH
  • Home
  • 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 242695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:51:33+00:00 2026-05-11T20:51:33+00:00

Folks, Please does anyone know how to show a Form from an otherwise invisible

  • 0

Folks,

Please does anyone know how to show a Form from an otherwise invisible application, and have it get the focus (i.e. appear on top of other windows)? I’m working in C# .NET 3.5.

I suspect I’ve taken “completely the wrong approach”… I do not Application.Run(new TheForm ()) instead I (new TheForm()).ShowModal()… The Form is basically a modal dialogue, with a few check-boxes; a text-box, and OK and Cancel Buttons. The user ticks a checkbox and types in a description (or whatever) then presses OK, the form disappears and the process reads the user-input from the Form, Disposes it, and continues processing.

This works, except when the form is show it doesn’t get the focus, instead it appears behind the “host” application, until you click on it in the taskbar (or whatever). This is a most annoying behaviour, which I predict will cause many “support calls”, and the existing VB6 version doesn’t have this problem, so I’m going backwards in usability… and users won’t accept that (and nor should they).

So… I’m starting to think I need to rethink the whole shebang… I should show the form up front, as a “normal application” and attach the remainer of the processing to the OK-button-click event. It should work, But that will take time which I don’t have (I’m already over time/budget)… so first I really need to try to make the current approach work… even by quick-and-dirty methods.

So please does anyone know how to “force” a .NET 3.5 Form (by fair means or fowl) to get the focus? I’m thinking “magic” windows API calls (I know

Twilight Zone: This only appears to be an issue at work, we’re I’m using Visual Studio 2008 on Windows XP SP3… I’ve just failed to reproduce the problem with an SSCCE (see below) at home on Visual C# 2008 on Vista Ulimate… This works fine. Huh? WTF?

Also, I’d swear that at work yesterday showed the form when I ran the EXE, but not when F5’ed (or Ctrl-F5’ed) straight from the IDE (which I just put up with)… At home the form shows fine either way. Totaly confusterpating!

It may or may not be relevant, but Visual Studio crashed-and-burned this morning when the project was running in debug mode and editing the code “on the fly”… it got stuck what I presumed was an endless loop of error messages. The error message was something about “can’t debug this project because it is not the current project, or something… So I just killed it off with process explorer. It started up again fine, and even offered to recover the “lost” file, an offer which I accepted.

using System;
using System.Windows.Forms;

namespace ShowFormOnTop {
    static class Program {
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            Form1 frm = new Form1();
            frm.ShowDialog();
        }
    }
}

Background: I’m porting an existing VB6 implementation to .NET… It’s a “plugin” for a “client” GIS application called MapInfo. The existing client “worked invisibly” and my instructions are “to keep the new version as close as possible to the old version”, which works well enough (after years of patching); it’s just written in an unsupported language, so we need to port it.

About me: I’m pretty much a noob to C# and .NET generally, though I’ve got a bottoms wiping certificate, I have been a professional programmer for 10 years; So I sort of “know some stuff”.

Any insights would be most welcome… and Thank you all for taking the time to read this far. Consiseness isn’t (apparently) my forte.

Cheers. Keith.

  • 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-05-11T20:51:33+00:00Added an answer on May 11, 2026 at 8:51 pm

    Simply

    yourForm.TopMost = true;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI folks, I have a .net application (vb.net) and I'm using the ajax control
I have a problem that needs some suggestions from you folks. Example: selling_price =
Folks, We have been using OpenXml APIs found in System.IO.Packaging for creating a package
Folks, is there a collection of gotchas where Numpy differs from python, points that
Folks, I'm tryning to extract data from web page using C#.. for the moment
Folks, I have a problem. I am a writing a script in python which
Folks, I've got an ASP.NET MVC application that I am attempting to secure using
Folks, I need to maintain a C#/.Net desktop application. So, I need to set
Update: fixed delta calculations in code, still the issue remains Folks, could you please
Ok fine folks of Stack Overflow, I have a question and I can't seem

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.