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 6667905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:58:58+00:00 2026-05-26T02:58:58+00:00

FormCollection fc = Application.OpenForms; foreach (Form frm in fc) { //iterate through } OR

  • 0
FormCollection fc = Application.OpenForms;

foreach (Form frm in fc)
{
//iterate through
}

OR

Form fc = Application.OpenForms["FORMNAME"]; if (fc != null) fc.Close(); fm.Show();

but non of this works in compact framework 3.5. How can i check if form is already opened in CF 3.5?

  • 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-26T02:58:58+00:00Added an answer on May 26, 2026 at 2:58 am

    As @Barry wrote, you will have to do it yourself. Easiest way is to use a dictionary. Your key can be a form’s type, its name, or whatever you need.

    private static readonly Dictionary<string, MyForm> _dict 
        = new Dictionary<string, MyForm>();
    
    public MyForm CreateOrShow(string formName)
    {
        Form f = null;
        if (!_dict.TryGetValue(formName, out f))
        {
            f = new MyForm();
            _dict.Add(formName, f);
        } 
        return f;
    }
    

    Or, if you want to support multiple form types and want to avoid casting, use a generic method:

    private static readonly Dictionary<string, Form> _dict 
        = new Dictionary<string, Form>();
    
    public T CreateOrShow<T>(string formName) where T : Form, new()
    {
        Form f = null;
        if (!_dict.TryGetValue(formName, out f))
        {
            f = new T();
            _dict.Add(formName, f);
        }
        return (T)f;
    }
    
    public T CreateOrShow<T>(string formName, Func<T> ctor) where T : Form
    {
        Form f = null;
        if (!_dict.TryGetValue(formName, out f))
        {
            f = ctor();
            _dict.Add(formName, f);
        }
        return (T)f;
    }
    

    There are two generic overloads. One of them is used like this:

    // use this if MyFormType has a parameterless constructor
    var form = CreateOrShow<MyFormType>("Form1");
    

    or, if you need to pass parameters to your form during init:

    // use this if MyFormType accepts parameters in constructor
    var form = CreateOrShow<MyFormType>("Form1", () => new MyFormType(someData));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FormCollection and I just want to only iterate through the keys
How can I improve this username/password checking? [AcceptVerbs(HttpVerbs.Post)] public ActionResult Login(FormCollection collection) { var
My FormCollection is returning back a Checkbox, but I am after the value collection[SelectedCheckbox]
My action is : [HttpPost] public ViewResult SearchPost(FormCollection frm) { IList <post> p =db.posts.Include(user).ToList();
I have a controller with the codes like this: [AcceptVerbs(POST)] public ActionResult Create(FormCollection collection)
I have the following method public ActionResult Search(FormCollection form) { ....... Publication[] publicationsResult =
This is a code fragment from my controller [HttpPost] public ActionResult Cancel(string id,FormCollection collection)
I'm getting this error intermittently on my MVC 2 web application. My models do
Trying to close all forms except for the main menu using FormCollection formsList =
I written a method that Hide or Show all forms of application(including forms children).

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.