【发布时间】:2016-05-06 03:49:01
【问题描述】:
我正在为 c#.net 中的计算器编码。我在 txtDisplay.Text 中的 txtDisplay 上有一条错误消息。错误说“当前上下文中不存在名称'txtDisplay'”。到目前为止我的代码是:
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Calc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnOne_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnOne.Text;
}
【问题讨论】:
-
您还需要显示
partial类的其他部分。 -
我认为 txtDisplay 是您表单上的一个文本框。你真的在设计器模式下添加了吗?