windowsforms.jpg (2484 bytes)

Writing Windows Forms Controls

Many application developers need the ability to write their own Windows Form Controls not only in their software, but also for profitability to third party vendors.  Windows Forms Controls in .NET, like everything else, has been made easy and available.

The first step in writing a control is to derive a class from the base class system System.Windows.Forms.UserControl.  Then comes the coding.  An example can be found below.

Public Class UserControl

 Inherits System.Windows.Forms.UserControl

 Private myShowSeconds As Boolean

 Public Property ShowSeconds() As Boolean
  Get
   Return myShowSeconds
  End Get

  Set
   MyShowSeconds = Value
  End Set
 End Property
 Protected Oveeides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

 End Sub
End Class

This example writes the time on a Windows Form with a different background.  The background is set with the use of the OnPaint notification.  This overrides the default value when it reaches the CLR.

One problem programmers may sense is the fact that not many .NET applications are being used at the moment.  This is not a problem because the UserControl base class has all the functionality in order to be accessible to ActiveX server controls such as with Visual Basic.  In order to have the .NET applications accessible to the Visual Basic applications running with ActiveX, the programmer must set two prefabricated functions for use with the CLR.  These functions are the

ActiveXRegister(foo.GetType)

And

ActiveXUnregister(foo.GetType)

This is just a taste of what Windows Forms can do in .NET.  Hopefully some knowledge has been derived and peaked the interests of some VB and VC users.