Der*_*unk 5 c# console winforms
我想使用C#从控制台生成Windows窗体.大致与displayLinux 相似,并修改其内容等.这可能吗?
您应该能够为System.Windows.Forms添加引用,然后就可以了.您可能还必须将STAThreadAttribute应用于应用程序的入口点.
using System.Windows.Forms;
class Program
{
[STAThread]
static void Main(string[] args)
{
MessageBox.Show("hello");
}
}
Run Code Online (Sandbox Code Playgroud)
... 更复杂 ...
using System.Windows.Forms;
class Program
{
[STAThread]
static void Main(string[] args)
{
var frm = new Form();
frm.Name = "Hello";
var lb = new Label();
lb.Text = "Hello World!!!";
frm.Controls.Add(lb);
frm.ShowDialog();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14588 次 |
| 最近记录: |