Example: A Windows Forms Application

The example program in Listing D.3 implements a simple Windows Forms application. The HelloWorldForm class inherits from the System.Windows.Forms.Form base class. It adds a text box and a button to the form. When the user clicks the button, a message box displays the text from the text box.

Listing D.3.
 package HelloWorldForm; use strict; use PerlNET qw(with AUTOCALL); use namespace "System"; use namespace "System.Windows.Forms"; use namespace "System.Drawing"; =for interface [extends: Form] [STAThread] static void Main(); private field TextBox textBox; private void Click(any sender, EventArgs Args); =cut sub Main { my $self = HelloWorldForm->new; Application->Run($self); } sub HelloWorldForm { my $this ...

Get Programming in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.