Forms in Class Libraries - Beginners Question

  • Thread starter Thread starter Roger Stenson
  • Start date Start date
R

Roger Stenson

Hi
I am just beginning learning Dot Net, though I am a fairly experienced VB6
traditional developer.

I have a Solution which contains of libraries of classes which I want to
reuse widely in multiple projects , including some forms which I want to
inherit. These forms need to show the output of the back -office classes
often using 'MessageBox.Show.

Because the form is stored in a class library it seems to have lost some
function including MessageBox. Is there a simple way round this by importing
the right namespace or is this a no-no for Windows forms stored in Class
Libraries

Roger Stenson
 
Hello,

To show a MessageBox or a Form from a class library you will need to add a
reference to System.Windows.Forms. The MessageBox is in the
System.Windows.Forms namespace. If you are using it from a class you will
need to use/import the name space or write it out completely like
System.Windows.Forms.MessageBox.Show("Hello World");

In your main application you will need to add a reference to the class
library.

Hope that helps,

Tom Krueger

Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.
 
Hi Tom

Thanks enormously for your help with my beginners problems.

I imagined MessageBox came from System.Windows.Forms.Form as I don't recall
importing System.Windows.Forms as well as inheriting the 'form' when
developing an ordinary forms application.

Anyway you have solved the problem and thanks

Roger Stenson
 
Back
Top