Form login = new Form("请登陆");//显示了一个基本的界面,没有任何控件。如果需要控件,你必须自己添加上去。另外注意各个控件的location。然后添加按钮的时候注意注册事件。

解决方案 »

  1.   

    我上面的回答错误了。Form没有Form(string temp)这样的构着函数。你需要的效果以前一位高人写了文章讨论过。具体你可以搜搜。我写了个例子程序如下:
    -----------------------------------------------------------
    using System;
    using System.Windows.Forms;
    class test
    {
    Form frm = new Form();
    Button btnOK = new Button();
    TextBox txtPsw = new TextBox();

    static void Main(string [] args)
    {
    test temp = new test();
    temp.showFrm();
    //Console.ReadLine();
    }

    private void showFrm()
    {
    btnOK.Text = "确定";
    frm.Text = "登陆";
    txtPsw.Location = new System.Drawing.Point(10,10);
    btnOK.Location = new System.Drawing.Point(txtPsw.Left,txtPsw.Top + txtPsw.Height + 10);
    btnOK.Click += new System.EventHandler(btnOKClick);
    frm.FormBorderStyle = FormBorderStyle.FixedDialog;
    frm.Controls.Add(txtPsw);
    frm.Controls.Add(btnOK);
    frm.StartPosition = FormStartPosition.CenterScreen;
    frm.ShowDialog();
    }

    private void btnOKClick(object sender, System.EventArgs e)
    {
    //验证信息
    MessageBox.Show(txtPsw.Text);
    }
    }csc test.cs就可以了。
    参考:ms-help://MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemWindowsFormsFormMethodsTopic.htm