Results 1 to 4 of 4

Thread: Forms in DLL files?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2016
    Posts
    41

    Forms in DLL files?

    Hi,

    Can you create dll files with forms/gui in them, or can they only contain code?

    Thanks,
    Sijcooke

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Forms in DLL files?

    Forms are just classes like any other. Of course you can create them in DLLs. The Form class itself is defined in a DLL, as are all the control classes you can put on a form. Just as with any other type, you need to have referenced the required libraries. When you create a project, select Windows Forms Control Library rather than Class Library and the required assemblies will be referenced by default, i.e. the same ones as for a Windows Forms Application project.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Forms in DLL files?

    If you are doing Windows Forms, and you create a Class Library, you just need to add a reference to Windows.Forms to get all that functionality. That may be the sole difference between Windows Forms Control Library (which I hadn't heard of) and a typical Class Library (which is what I use for all dll projects).
    My usual boring signature: Nothing

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,296

    Re: Forms in DLL files?

    The Windows Forms Control Library has some additional assembly references and namespace imports, e.g. System.Drawing. The other main difference is that the default item is a user control rather than a simple class. No help if you don't want a user control, of course, but it can be deleted easily enough. Mind you, if you do create a Class Library project and then add a Windows Form item to it in the Solution Explorer, the required references will be added automatically, although the namespace imports will not. That rather begs the question of why this needed to be asked in the first place. Simply trying to add a form would have made it obvious that it was possible. You really ought to always look first and ask questions later.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width