Building Windows Applications in C# Visual Studio

Posted on 2006-04-17
Last Modified: 2010-04-16
I am a college student who is new to building application is Visual Studio. I currently have opened a new windows application project in Visual Studio 2005 and has the bare skeleton structure.

This is what I want to do:

1) Create a class diagram. Automatically generate the code based on the class diagram. I already have the class diagram built in Microsoft Visio 2003. If there is a way to import that into Visual Studio 2005, that would be nice too.

2) Write the necessary code in the main() and in the necessary classes generated by the class diagram.

3) Successfully compile ("Build") and run the program.

My Questions:

1) Strategy of how I should accomplish the above with respect to the empty skeleton structure of the code that currently exists.

2)  An brief explanation of what I should know about the following in the skeleton structure of "Program.cs" main method() i.e.:-
        static void Main()
            Application.Run(new Form1());


Question by:scarface7
    1 Comment
    LVL 12

    Accepted Solution



    I am not sure about the compatibility of VS2003 to VS2005 but try to add the existing class diagram to VS2005.  Right click on the project and select add|new item and choose a class diagram from the resulting dialog.  If this doesn't work then create the diagram in VS2005.  The code automatically generated as you add classes, methods, properties etc.

    Write whatever your necessary code is.  This is a windows application so a form class will have to be instatiated in the main.  Your app starts when that form is displayed.  You then put controls (buttons, labels etc).  For example you can create a click event for one of the buttons you put on the form, then in that click event you can use your other classes to perform a task (display some info, read a file etc)


    The above line is to do with how controls are displayed.  This line has no effect on your code, it is for WinXP and later special visual rendering of controls

    (From MSDN)
    This method enables visual styles for the application. Controls will draw with visual styles if the control and the operating system support it. To have an effect, EnableVisualStyles must be called before creating any controls in the application; typically, EnableVisualStyles is the first line in the Main function. A separate manifest is not required to enable visual styles when calling EnableVisualStyles.


    (From MSDN blogs)
    Certain Windows Forms controls can render their text using either the GDI graphics library, or the newer GDI+ library. This change was made because of performance and localization issues with GDI+. By default, existing controls that support the UseCompatibleTextRendering property are set to true for backwards compatibility, but all new controls in environments such as Visual Studio have this property set to false. Use SetCompatibleTextRenderingDefault when you wish to switch the default text rendering for new controls.

    You should never call this method if your Windows Forms code is hosted in another application, such as Internet Explorer. Only call this method in stand-alone Windows Forms applications.

    No sample code, since the call is very simple. Just stick this in your Main() method before calling Application.Run(), and you're set.

    Application.Run(new Form1());

    This line starts your application loading a new instance of form1.  Form1 is your start point, you then access other forms/classes in your app from Form1


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Live - One-on-One C# Help from Top Experts

    Solve your toughest problems, fast.
    C# experts are online now and ready to help you.

    Suggested Solutions

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now