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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
buttonOK.Enabled = false;
} private void buttonOK_Click(object sender, EventArgs e)
{
string output;
output = "Name: " + this.textBoxName.Text + "\r\n";
output += "Address: " + this.textBoxAddress.Text + "\r\n";
output += "Occupation: " + this.textBoxOccupation.Text + "\r\n";
output += "Age: " + this.textBoxAge.Text;
this.textBoxOutput.Text = output;
} private void buttonHelp_Click(object sender, EventArgs e)
{
string output;
output = "Name: " + this.textBoxName.Text + "\r\n";
output += "Address: " + this.textBoxAddress.Text + "\r\n";
output += "Occupation: " + this.textBoxOccupation.Text + "\r\n";
output += "Age: " + this.textBoxAge.Text;
this.textBoxOutput.Text = output;
} private void textBoxEmpty_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb.Text.Length == 0)
tb.BackColor = Color.Red;
else
tb.BackColor = System.Drawing.SystemColors.Window;
ValidateOK(); //这里出错
} private void textBoxOccupation_Validating(object sender, CancelEventArgs e)
{ }
}错误在红色那里 ValidateOK(); Error显示:
The name 'ValidateOK' does not exist in the current context
求解答,为什么错. 书的例子是这样写的.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
buttonOK.Enabled = false;
} private void buttonOK_Click(object sender, EventArgs e)
{
string output;
output = "Name: " + this.textBoxName.Text + "\r\n";
output += "Address: " + this.textBoxAddress.Text + "\r\n";
output += "Occupation: " + this.textBoxOccupation.Text + "\r\n";
output += "Age: " + this.textBoxAge.Text;
this.textBoxOutput.Text = output;
} private void buttonHelp_Click(object sender, EventArgs e)
{
string output;
output = "Name: " + this.textBoxName.Text + "\r\n";
output += "Address: " + this.textBoxAddress.Text + "\r\n";
output += "Occupation: " + this.textBoxOccupation.Text + "\r\n";
output += "Age: " + this.textBoxAge.Text;
this.textBoxOutput.Text = output;
} private void textBoxEmpty_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb.Text.Length == 0)
tb.BackColor = Color.Red;
else
tb.BackColor = System.Drawing.SystemColors.Window;
ValidateOK(); //这里出错
} private void textBoxOccupation_Validating(object sender, CancelEventArgs e)
{ }
}错误在红色那里 ValidateOK(); Error显示:
The name 'ValidateOK' does not exist in the current context
求解答,为什么错. 书的例子是这样写的.
你上下文中没有这个方法,这个方法在哪里?
方法没有定义