日期:2014-05-18  浏览次数:20841 次

麻烦哪位高手帮我看一下这个winform程序
小弟学习winform窗口程序,按照课本上的调试但无法成功,请大神指教一下,小弟感激不尽。。程序如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace 登陆
{
  static class Program
  {
  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);
  LoginForm frm1 =new LoginForm("CS","8888")
  if (frm1.ShowDialog() ==DialogResult.Cancel)return;
  Application.Run(new Form1());
  }
  }
}
这个是MAIN函数一下的,然后我自己建了一个Loginform的窗体,程序如下




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 登陆
{
  public partial class LoginForm : Form
  {
  private int count = 0;
  private string user, pwd;

  public LoginForm(string user, string pwd)
  {
  InitializeComponent();
  this.user = user;
  this.pwd = pwd;
  button1.Click += new EventHandler(button1_Click);
  }
  void button1_Click(object sender, EventArgs e)
  {
  if (textBox1.Text == user && textBox2.Text == pwd)
  this.DialogResult = DialogResult.OK;
  else
  {
  MessageBox.Show("密码错误", "警告");
  if (count++ == 3)
  this.DialogResult = DialogResult.Cancel;
  }
  }

  private void LoginForm_Load(object sender, EventArgs e)
  {

  }
  }
}


不知道要怎么才能把那个窗口调试出来,总是有错误。。。谢谢指教







------解决方案--------------------
然后
右键该项目→清理,再右键该项目→重新生成。最后再调试,应该就没有问题了,Good Luck!