By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,170 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,170 IT Pros & Developers. It's quick & easy.

C# can't create Window Forms?

P: n/a
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...;-) )
Jan 26 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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();
}
}
}
Jan 26 '07 #2

P: n/a
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

"Marc Gravell" <ma**********@gmail.comschreef in bericht
news:ec**************@TK2MSFTNGP04.phx.gbl...
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();
}
}
}


Jan 26 '07 #3

P: n/a
(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.
"Henk van Winkoop" <h.***********@wxs.nlwrote in message
news:45***********************@text.nova.planet.nl ...
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

"Marc Gravell" <ma**********@gmail.comschreef in bericht
news:ec**************@TK2MSFTNGP04.phx.gbl...
>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();
}
}
}



Jan 26 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.