0

I am working windows mobile application in compact framework 3.5.I want to close a windows form from another windows form.

I tried like below,

Book newform = (Book)Application.OpenForms["Book"];
newform.Close();

I am getting this error "'System.Windows.Forms.Application' does not contain a definition for 'OpenForms'".I checked in Application form and this OpenForms is not available.May i know the equivalent fix of OpenForms in compact framework or please provide me an alternative solution.

Thanks

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
Royal
  • 752
  • 2
  • 14
  • 29
  • possible duplicate of [Compact Framework - get all open forms](http://stackoverflow.com/questions/10278606/compact-framework-get-all-open-forms) – Blorgbeard Jul 03 '14 at 04:33
  • See link above: TL;DR: there is no such feature, you'll have to track your forms manually. – Blorgbeard Jul 03 '14 at 04:34

1 Answers1

1

There is no equivalent. The Compact Framework is compact because it doesn't include a lot of stuff that isn't needed. If you need to access a form later then keep a reference to it when you create it, which is what you should generally be doing in an application targeted at the full Framework anyway.

You don't necessarily have to create a class that tracks all forms, as is done in the link provided by Blogbeard. If this is just a one-off then just keep that one reference. If you need to do it lots for various forms, then a centralised form manager may be a better option.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46