C# can't create Window Forms?

H

Henk van Winkoop

Hello,

I downloaded 'Microsoft Visual C#' and the 'Programmers_Heaven_C_Schom.pdf'
to learn myself C#.

In the PDF it says that to create a Windows Form you need to add the line:
'using System.Windows.Forms'
but this 'using' is not in the auto-selection-list when typing nor is it
recognized by the compiler.

I can create a Window by menu: Project -> Add Windows Form...'
but then also no 'using System.Windows.Forms' is showing anywhere.

What's the relation between both methods? How do I have to see these things?

Regards,

Henk (confused...;-) )
 
M

Marc Gravell

OK - I'll assume you mean "Microsoft Visual C# 2005 Express
Edition"... using the standard templates, after Project -> Add Windows
Form... the code in Form1.cs looks like below. As for it not
recognising System.Windows.Forms when entered manually, this sounds
like a missing reference. Ensure that your project references
System.Windows.Forms.dll; note that console apps and class libraries
(etc) don't reference this by default, but you can add it. Also,
Project -> Add Windows Form... seems to conveniently add it for you.

Marc

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms; // EDIT: "here I am"

namespace MyTestApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
 
H

Henk van Winkoop

Thanks.,

I surfed through the menu 'Project' and found that:

Projetc -> Add Reference -> System.Windows.Forms

does the right stuff.

(as I'm used to Borland C++ and Microsoft VB/VBA each language has it's own
approach
that has to be learned.....;-) )

Henk
 
D

Daniel

(as I'm used to Borland C++ and Microsoft VB/VBA each language has it's
own approach
that has to be learned.....;-) )


Or in thus case you just didn't look very hard? ;) Read up on namespaces,
and in future use the 'find' command before posting such a question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top