为什么不存在?

moukyou 2003-01-07 02:37:37
一个计算器小程序。出错在这里
InitializeComponent();
提示信息是:InitializeComponent是类,不存在于名词空间wincalc.calcForm里


程序代码如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace wincalc
{
public class calcForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button0;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button bDot;
private System.Windows.Forms.Button bEqu;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button bDiv;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button bMul;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button bSub;
private System.Windows.Forms.Button bClr;
private System.Windows.Forms.Button bPlus;
private System.Windows.Forms.TextBox txtCalc;
double dblAcc;
double dblSec;
bool blnClear,blnFrstOpen;
string strOper;
private System.ComponentModel.Container components = null;
public calcForm()
{
InitializeComponent();
dblAcc=0;
dblSec=0;
blnFrstOpen=true;
blnClear=true;
strOper=new string('=',1);
}
……………………
...全文
61 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
moukyou 2003-01-07
  • 打赏
  • 举报
回复
各位抱歉!
我是自己笔误。少打个字母造成的。
kinglht 2003-01-07
  • 打赏
  • 举报
回复
把InitializeComponent();放到构造函数中!
hongshun 2003-01-07
  • 打赏
  • 举报
回复
:) 我的方法 简直 是 脚疼 医 脚。

InitializeComponent();


方法体中 的代码 你是不是 手工删除了 ???


GiantHard 2003-01-07
  • 打赏
  • 举报
回复
你是不是把InitializeComponent方法给注解或删减掉了,此方法是窗体设计器自动生成的!
moukyou 2003-01-07
  • 打赏
  • 举报
回复
hongshun(好好)
注释掉没有用
注释以后可以正常编译运行,但是form是一个空的。上面的按钮什么的都不见了。
csdn_bob 2003-01-07
  • 打赏
  • 举报
回复
public calcForm()
这样写不对吧!是函数?是??
hongshun 2003-01-07
  • 打赏
  • 举报
回复
public calcForm()
{
//InitializeComponent();
dblAcc=0;
dblSec=0;
blnFrstOpen=true;
blnClear=true;
strOper=new string('=',1);
}
……………………

110,534

社区成员

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

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

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