错误 1 找不到类型或命名空间名称“Form1”(是否缺少 using 指令或程序集引用?)

liyansudu778 2011-09-08 10:41:07
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace WindowFormsApplication1
{
public partial class Form1 : Form
{
private string struser = "";
public string user { get { return struser; } set { struser = value; } }
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{ tsslUser.Text = "当前用户:" + user; }
private void timer1_Tick(object sender, EventArgs e)
{
time.Text = "当前时间:" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" +

DateTime.Now.Day + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" +

DateTime.Now.Second;
}
private void Form1Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("您是否真的退出系统", "提示", MessageBoxButtons.YesNo,

MessageBoxIcon.Question) == DialogResult.Yes)
{ System.Environment.Exit(0); }
else
{
e.Cancel = true;
}
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Escape:
if (MessageBox.Show("您是否真的退出系统", "提示", MessageBoxButtons.YesNo,

MessageBoxIcon.Question) == DialogResult.Yes) { System.Environment.Exit(0); } break;
}

}
}
}
...全文
1671 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lijie_255456 2011-09-08
  • 打赏
  • 举报
回复
那一句代码报错呢?
bdmh 2011-09-08
  • 打赏
  • 举报
回复
你确认是这个文件出错吗,另外Form1Main_FormClosing,这是个什么
风骑士之怒 2011-09-08
  • 打赏
  • 举报
回复
哪里出错呢,
夏天的鱼 2011-09-08
  • 打赏
  • 举报
回复
楼主你好,你新建的工程默认名字应该是namespace WindowsApplication1
不知道你为什么是namespace WindowFormsApplication1
把它改过来就行了,注意其他地方也要一致

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧