English 中文(简体)
如何在 but被点击时展示一种形式?
原标题:How to show a form when a button is clicked?

在C#应用i m编码时,我正确地点击了我关于解决方案探索者的项目,然后去Add,然后选择了视窗表格和选定的视窗表格,并用Ok!

然后,我把我的电文命名为我的电文,而不是默认名称(表2)

现在,我以我的形式增加了一个纽州,希望本纽顿在我点击时向我展示另一种形式(电文),这样我的代码就是:

 MessageForm Frm = new MessageForm();
        Frm.Show();

但有错误,一 could编成法典,因为:

 Error  1   The type or namespace name  MessageForm  could not be found (are you missing a using directive or an assembly reference?)

如何做到这一点?

问题回答

我怀疑,你只是将<代码>Form2.cs文档改名为MessageForm.cs,但不是该档案中的实际名称。 在添加Windows Form dialog中点韩国之前,请将Form2.cs改为MessageForm.cs。 这样,档案和类型就会被正确地点名。 但是,如果已经存在这种表格,你可以浏览相应的档案并替换:

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }
}

public partial class MessageForm : Form
{
    public MessageForm()
    {
        InitializeComponent();
    }
}




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签