locked
Starting from a blank project RRS feed

  • Question

  • Greetings,

    I decided to explore deeper into how blank forms and controls are created.

    I don't know where to start. I'm not expert by any means I believe I just now the basics.

    I tried and start new project but instead of windows form template I used Blank Project. Added a module and creating sub main.

    I created a new class and copied few lines from a previous project and it gave me several errors.

    Brushes, Color, Font, Graphics are not defined. I am not sure if it's correct but when I added System.Drawing Reference and System.Drawing Namespace the errors was removed.

    Moreover, 'My' is not declared.

    I would like to know what basic references and namespaces I need to add.

    (Note: I tried to add all the referenced and namespaces found when I create a windows form project but the errors was not removed)

    Moreover, I would like to know how to create my own form and controls. Links and tutorials will be much appreciated.

    Sunday, June 3, 2012 1:58 AM

Answers

  • Start a Windows Forms project.  A default form is created.  Choose Project / Properties / References.  The references and imported namespaces listed there are the defaults included with that type of project.

    You could add what you need from that list to a blank project.

    The My namespace is a bit different - it is actually defined in the project and is created as needed.  It's in the Settings.Designer.vb file.

    Sunday, June 3, 2012 10:32 AM
  • Would it not be the same if I added new class file in the 'Windows Form'.

    Nearly the same.  Using a class library means the code compiles to a DLL which is then directly accessible to any project.  There's nothing particularly magic about a control - it's just another class.

    Plus how to use it to create the design, events.

    Inherit from Control, or inherit from any existing control if that is suitable.  That gives you all the events, properties and methods you need for a basic component, including support for the properties dialogue.   Add the graphical components, if it's a GUI control.  Then add your custom events, methods etc.

    I know how to create properties, methods and know the basics about GDI+

    Then you probably know enough to work from any of the available control examples.  For a class library, your solution will have two projects - the component and a standard windows forms application that you will use to test that component.   Once that structure is set up in the solution, the development is quite straightforward.

    Sunday, June 3, 2012 12:47 PM

All replies

  • Start a Windows Forms project.  A default form is created.  Choose Project / Properties / References.  The references and imported namespaces listed there are the defaults included with that type of project.

    You could add what you need from that list to a blank project.

    The My namespace is a bit different - it is actually defined in the project and is created as needed.  It's in the Settings.Designer.vb file.

    Sunday, June 3, 2012 10:32 AM
  • I added settings.designer.vb file and the Error changed to 'computer','forms' in not a member of 'My'.

    Moreover, 2 new errors appeared:
    "'Partical_Simulation' is not a member of '<Default>'."

    "Type 'Partical_Simulation.My.MySettings' is not defined."

    Sunday, June 3, 2012 10:45 AM
  • Never mind the 2 new errors.

    I found that they was in the settings file and changed the name to the correct name of the solution.

    Sunday, June 3, 2012 11:06 AM
  • You can't just add the designer file and expect it to work. It needs code.   You can create the code manually, or you can use the Settings page in project properties to create the code for you.

    Partical_Simulation is not part of any standard namespace that I am aware of.  You probably need a custom namespace.  Add it in the same way that you added the others.

    What are you hoping to achieve by building a forms project from blank?   It's a lot of work that the IDE can do for you.  

    Sunday, June 3, 2012 11:08 AM
  • I guess then that is beyond my level.

    Hmm.. how about creating a 'Windows Forms Application' project and create  new controls. Would that be easier? And how?

    Sunday, June 3, 2012 11:19 AM
  • Do you mean 'create new controls or 'add controls to a windows form'?  

    To create a windows forms project use the windows forms template and add controls from the toolbox.

    To create a control, use the Class Library template. That is used for classes, including GUI controls, that are accessed as components in a forms project. 

    Sunday, June 3, 2012 11:50 AM
  • Would it not be the same if I added new class file in the 'Windows Form'.

    Plus how to use it to create the design, events.

    I know how to create properties, methods and know the basics about GDI+

    Will that be still a lot to learn for my level?

    Note: I'm willing to learn something new.

    Sunday, June 3, 2012 12:01 PM
  • Would it not be the same if I added new class file in the 'Windows Form'.

    Nearly the same.  Using a class library means the code compiles to a DLL which is then directly accessible to any project.  There's nothing particularly magic about a control - it's just another class.

    Plus how to use it to create the design, events.

    Inherit from Control, or inherit from any existing control if that is suitable.  That gives you all the events, properties and methods you need for a basic component, including support for the properties dialogue.   Add the graphical components, if it's a GUI control.  Then add your custom events, methods etc.

    I know how to create properties, methods and know the basics about GDI+

    Then you probably know enough to work from any of the available control examples.  For a class library, your solution will have two projects - the component and a standard windows forms application that you will use to test that component.   Once that structure is set up in the solution, the development is quite straightforward.

    Sunday, June 3, 2012 12:47 PM
  • Thanks a lot for your help.

    I think I am starting to get the picture.

    If you can give me a link for a sample it would be much appreciated.

    Sunday, June 3, 2012 12:53 PM