首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

初学者求教C#程序有关问题(哪错了呢)

2012-01-05 
菜鸟求教C#程序问题(哪错了呢)using Systemusing System.Collections.Genericusing System.ComponentMod

菜鸟求教C#程序问题(哪错了呢)
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 WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
  private void Validate(object sender1, object sender2)
  {
  TextBox tb = (TextBox)sender1;
  Label lb1 = (Label)sender2;
  if (tb.Text.Length == 0)
  {
  lb1.Visible = true;
  lb1.Text = "此项不能为空!";
  lb1.BackColor = Color.Red;
  }
  }

  public Form1()
  {
  InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {

  }

  private void textBox1_Validating(object sender, CancelEventArgs e)
  {
  Form f = new Form1();
  f.Validate(textBox1,label1);
  }
  }
}


[解决办法]
Form f = new Form1();
f.Validate(textBox1,label1);

=>

Validate(textBox1,label1);

热点排行