storing cutom UI components

  • Thread starter Thread starter Homer Simpson
  • Start date Start date
H

Homer Simpson

Hi everyone,

How do I create buttons, forms, etc and store them outside my project so I
can import them into other projects? For example, I would like to create an
OK button with certain properties (size, labels, etc) and events without
recreating it every I need to use one of these buttons.

Thanks,
Scott
 
Create a "Windows Control Library" or "Class Library" project and inherit
your class from the appropriate control or UserControl class. So for a
custom button you could create a class, let's say AcceptButton, and inherit
from the System.Windows.Forms.Button class. There are examples of creating
custom controls at The Code Project
(http://www.codeproject.com/cs/miscctrl/). You should also be able to find
lots of examples through MSDN (http://msdn.microsoft.com/) and Google. Once
you've compiled the project into an assembly you can add the controls to the
ToolBox so that you can drag and drop them onto your Form or you could
manually add the assembly as a reference.
 
Back
Top