Windows Forms


This API is a part of .NET Framework 3.0
This API is a part of .NET Framework 3.0

Windows Forms is the name given to the graphical user interface application programming interface (API) included as a part of Microsoft's .NET Framework, providing access to the native Microsoft Windows interface elements by wrapping the existing Windows API in managed code. While it is seen as a replacement for the earlier and more complex C++ based Microsoft Foundation Class Library, it does not offer a paradigm comparable to model-view-controller. Some after-market and third party libraries have been created to address this issue. The most widely used of these is the User Interface Process Application Block, which is released by the Microsoft patterns & practices group as a free download that includes the source code for quick start examples.

Contents

History and future

Just like AWT, the equivalent Java API, Windows Forms was an early and easy way to provide GUI components to the .NET Framework. Also like AWT, it is a thin-wrapper on the underlying Windows platform, and it is difficult to specialize existing components or even to create new ones.[citation needed]

The Windows Presentation Foundation address these problems by providing a much more platform-independent way of designing Graphical user interfaces. Windows Forms has been in effect superseded by WPF (and its associated GUI declarative language called XAML), leading some to think that, whilst it will still be supported in future .NET releases, no new features would be added to Forms in the future[1][2][3].

Architecture

A Windows Forms application is an event-driven application supported by Microsoft's .NET Framework. Unlike a batch program, it spends most of its time simply waiting for the user to do something like fill in a text box or click a button (control).

BackgroundWorker is a utility class. Calling time-consuming code directly from the GUI classes will work, but it will perform in the same thread as the main GUI thread, so if the method needs time to perform, the GUI will freeze during this time. It is useful when a time-consuming task has to be performed following a user-interaction event, as it executes the code in another background thread before returning the result to the main GUI thread (SwingWorker is the equivalent Java class).

Hello world example

The following is a simple C# program using Windows Forms.

using System;
using System.Windows.Forms;
 
public class HelloWorld
{
   public static void Main()
   {
      MessageBox.Show("Hello world!");
   }
}

Alternative implementation

Mono is a project led by Novell (formerly by Ximian) to create an Ecma standard compliant .NET compatible set of tools.

As of 13 May 2008, Mono's System.Windows.Forms 2.0 is API complete (contains 100% of classes, methods etc. in Microsoft's System.Windows.Forms 2.0); also System.Windows.Forms 2.0 works natively on Mac OS X[citation needed].

See also

References

  1. ^ Smith, Josh (2007-09-05). "WPF vs. Windows Forms". Retrieved on 2008-07-26.
  2. ^ Harsh, Mike (2004-09-20). "WPF vs. Windows Forms". Retrieved on 2008-07-26. “If you’re targeting only Windows XP and Longhorn, Avalon is the way to go. But Windows Forms is still the only way to write managed UI that will run on Win 2K and below
  3. ^ Chand, Mahesh (2008-05-08). "Future of Windows Forms and ASP.NET". Retrieved on 2008-07-26.

External links


! __







Why are we here?
All text is available under the terms of the GNU Free Documentation License
This page is cache of Wikipedia. History