对其中的控件有了定义后 在执行的时候有这样的问题
错误 1 “calcdemo.Form1”并不包含“textBox1_TextChanged”的定义 D:\programs\calcdemo\calcdemo\Form1.Designer.cs 193 71 calcdemo其中form1.cs里面的内容是这样的:没有问题 但是在运行的时候在Form1.desiner.cs中有了以上的错误 大虾们 帮我看看这个计算器 为什么那个文本框里面不能显示输入的数字和计算出来的结果呢????? 新手不尽感激啊.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace calcdemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i = 0;
double x = 0.0;
double y = 0.0;
int z = 0;
int j = 0;
private void IncreaseI()
{
if (i % 2 == 0)
{
x = z;
}
else if (i % 2 == 1)
{
y = z;
}
i++;
if (i > 1)
{
i = 0;
}
textBox1.Text = z.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
z = 0;
IncreaseI();
}
private void button4_Click(object sender, EventArgs e)
{
z = 1;
IncreaseI();
}
private void button5_Click(object sender, EventArgs e)
{
z = 2;
IncreaseI();
}
private void button6_Click(object sender, EventArgs e)
{
z = 3;
IncreaseI();
}
private void button8_Click(object sender, EventArgs e)
{
z = 4;
IncreaseI();
}
private void button9_Click(object sender, EventArgs e)
{
z = 5;
IncreaseI();
}
private void button10_Click(object sender, EventArgs e)
{
z = 6;
IncreaseI();
}
private void button12_Click(object sender, EventArgs e)
{
z = 7;
IncreaseI();
}
private void button13_Click(object sender, EventArgs e)
{
z = 8;
IncreaseI();
}
private void button14_Click(object sender, EventArgs e)
{
z = 9;
IncreaseI();
}
private void button15_Click(object sender, EventArgs e)
{
j = 1;
}
private void button11_Click(object sender, EventArgs e)
{
j = 2;
}
private void button7_Click(object sender, EventArgs e)
{
j = 3;
}
private void button3_Click(object sender, EventArgs e)
{
j = 4;
}
private void button2_Click(object sender, EventArgs e)
{
switch (j)
{
case 1:
textBox1.Text = Convert.ToString(x + y);
break;
case 2:
textBox1.Text = Convert.ToString(x - y);
break;
case 3:
textBox1.Text = Convert.ToString(x * y);
break;
case 4:
textBox1.Text = Convert.ToString(x / y);
break;
default:
break;
}
}
}}
纵观以上代码里面似乎没有发现有关于那个文本框的内容的实现的方法,该怎么修改呢???
错误 1 “calcdemo.Form1”并不包含“textBox1_TextChanged”的定义 D:\programs\calcdemo\calcdemo\Form1.Designer.cs 193 71 calcdemo其中form1.cs里面的内容是这样的:没有问题 但是在运行的时候在Form1.desiner.cs中有了以上的错误 大虾们 帮我看看这个计算器 为什么那个文本框里面不能显示输入的数字和计算出来的结果呢????? 新手不尽感激啊.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace calcdemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i = 0;
double x = 0.0;
double y = 0.0;
int z = 0;
int j = 0;
private void IncreaseI()
{
if (i % 2 == 0)
{
x = z;
}
else if (i % 2 == 1)
{
y = z;
}
i++;
if (i > 1)
{
i = 0;
}
textBox1.Text = z.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
z = 0;
IncreaseI();
}
private void button4_Click(object sender, EventArgs e)
{
z = 1;
IncreaseI();
}
private void button5_Click(object sender, EventArgs e)
{
z = 2;
IncreaseI();
}
private void button6_Click(object sender, EventArgs e)
{
z = 3;
IncreaseI();
}
private void button8_Click(object sender, EventArgs e)
{
z = 4;
IncreaseI();
}
private void button9_Click(object sender, EventArgs e)
{
z = 5;
IncreaseI();
}
private void button10_Click(object sender, EventArgs e)
{
z = 6;
IncreaseI();
}
private void button12_Click(object sender, EventArgs e)
{
z = 7;
IncreaseI();
}
private void button13_Click(object sender, EventArgs e)
{
z = 8;
IncreaseI();
}
private void button14_Click(object sender, EventArgs e)
{
z = 9;
IncreaseI();
}
private void button15_Click(object sender, EventArgs e)
{
j = 1;
}
private void button11_Click(object sender, EventArgs e)
{
j = 2;
}
private void button7_Click(object sender, EventArgs e)
{
j = 3;
}
private void button3_Click(object sender, EventArgs e)
{
j = 4;
}
private void button2_Click(object sender, EventArgs e)
{
switch (j)
{
case 1:
textBox1.Text = Convert.ToString(x + y);
break;
case 2:
textBox1.Text = Convert.ToString(x - y);
break;
case 3:
textBox1.Text = Convert.ToString(x * y);
break;
case 4:
textBox1.Text = Convert.ToString(x / y);
break;
default:
break;
}
}
}}
纵观以上代码里面似乎没有发现有关于那个文本框的内容的实现的方法,该怎么修改呢???
给Form1类添加一个用于处理textBox1_TextChanged事件的函数:
void textBox1_TextChanged(Object sender, EventArgs e)
{
}
我想请问 方法体该怎么实现呢?为了实现其显示结果的功能!谢谢! 如果在Form1.Designer中把TextChanged事件删除掉的话 结果运行后 是这样的 我点了几个数字 但是文本框里面根本没有显示出来也就是不管这个计算器能否成功运算 我都不知道 该怎么继续处理呢????呵呵
删掉后结果运行后 只有那个计算器的界面 不管我输入什么数字 没有反应 结果不能也显示出来 那我就根本不知道这个计算器是否可以用哦 谢谢 帮忙解决 在那个TextChanged事件中我不知道该写什么程序进去 我对方法还不熟 谢谢
不要汗啊 我还没入门哦 我如果不删掉 显示会没有定义TextChanged
你书本上有说textbox是要做什么用的么?
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
把D:\programs\calcdemo\calcdemo\Form1.Designer.cs 193 71 calcdemo
中的this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
删了就好了
我在图书馆借了一本C#项目开发自学手册 然后看这个蛮过瘾的 就照着书上的全打了 基本上代码也看懂了 但是书上的代码偏偏就没有textbox 可能书上只显示了一部分的代码 .....我到现在就卡了