GUI在C#中没有的Visual Studio [英] GUI in C# without Visual Studio
本文介绍了GUI在C#中没有的Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,我在C#中的新手,但我需要创建一个简单的GUI,但我没有的Visual Studio(我用Geany和单声道)。
Okay, I'm a newbie in C# but I need to create a simple GUI, but I don't have Visual Studio (I use Geany and Mono).
现在的问题是,当我尝试下面的代码,我发现由谷歌:
The problem is, when I tried the following code that I found by Google:
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
public class FirstForm : Form
{
private Container components;
private Label howdyLabel;
public FirstForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
components = new Container ();
howdyLabel = new Label ();
howdyLabel.Location = new Point (12, 116);
howdyLabel.Text = "Howdy, Partner!";
howdyLabel.Size = new Size (267, 40);
howdyLabel.AutoSize = true;
howdyLabel.Font = new Font (
"Microsoft Sans Serif",
26, System.
Drawing.FontStyle.Bold);
howdyLabel.TabIndex = 0;
howdyLabel.Anchor = AnchorStyles.None;
howdyLabel.TextAlign = ContentAlignment.MiddleCenter;
Text = "First Form";
Controls.Add (howdyLabel);
}
public static void Main()
{
Application.Run(new FirstForm());
}
}
我在编译的时候只得到这些错误:
I just get these errors when trying to compile:
C:\C#\test2.cs(2,14): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System'. Are you missing an assembly reference?
C:\C#\test2.cs(4,14): error CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System'. Are you missing an assembly reference?
C:\C#\test2.cs(9,11): error CS0234: The type or namespace name 'Label' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 3 error(s), 0 warnings
我下载这两个DLL的,但我不知道下一步该怎么做。
链接代码: http://www.informit.com/文章/ article.aspx?p = 27316
推荐答案
您正在使用微软的WinForms UI库,其中单不包括。
You're using the Microsoft WinForms UI library, which Mono does not include.
您需要使用兼容Mono UI库,如GTK#。结果
你也可以使用的WinForms 的单端口。
You need to use a Mono-compatible UI library, such as GTK#.
You can also use the Mono port of WinForms.
这篇关于GUI在C#中没有的Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文