为什么总提示 No overload for TextBox1_KeyPress matches delegate System.Wind
ows.Forms.KeyPressEventHandler
/*
* Created by SharpDevelop.
* User: lvchao335
* Date: 2007-8-26
* Time: 11:00
*
* To change this template use Tools | Options | Coding | Edit Standard Header
s.
*/
namespace ddd
{
partial class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; ot
herwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The For
ms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox5 = new System.Windows.Forms.TextBox();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.AcceptsReturn = true;
this.textBox1.AcceptsTab = true;
this.textBox1.Location = new System.Drawing.Point(215, 2);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(153, 21);
this.textBox1.TabIndex = 0;
this.textBox1.TextChanged += new System.EventHandler(this.TextBox1TextChang
ed);
// this.KeyDown+= new System.Windows.Forms.KeyEventHandler(this.TextBox1KeyD
own);
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(thi
s.TextBox1_KeyPress);
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(215, 56);
this.textBox3.Name = "textBox3";
this.textBox3.PasswordChar = * ;
this.textBox3.Size = new System.Drawing.Size(153, 21);
this.textBox3.TabIndex = 2;
this.textBox3.TextChanged += new System.EventHandler(this.TextBox3TextChang
ed);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(215, 29);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = * ;
this.textBox2.Size = new System.Drawing.Size(153, 21);
this.textBox2.TabIndex = 1;
this.textBox2.TextChanged += new System.EventHandler(this.TextBox2TextChang
ed);
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(215, 111);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(153, 21);
this.textBox4.TabIndex = 4;
this.textBox4.TextChanged += new System.EventHandler(this.TextBox5TextChang
ed);
//
// label1
//
this.label1.Location = new System.Drawing.Point(160, 2);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(45, 21);
this.label1.TabIndex = 5;
this.label1.Text = "姓名 ";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(160, 29);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(45, 21);
this.label2.TabIndex = 6;
this.label2.Text = "密码 ";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(137, 55);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(58, 21);
this.label3.TabIndex = 7;
this.label3.Text = "确认密码";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label4
//
this.label4.Location = new System.Drawing.Point(160, 76);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(45, 21);
this.label4.TabIndex = 8;
this.label4.Text = "性别 ";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label5
//
this.label5.Location = new System.Drawing.Point(160, 111);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(45, 21);
this.label5.TabIndex = 9;
this.label5.Text = "住址 ";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(215, 153);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(59, 22);
this.button1.TabIndex = 5;
this.button1.Text = "确认";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// button2
//
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button2.Location = new System.Drawing.Point(309, 153);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(59, 22);
this.button2.TabIndex = 6;
this.button2.Text = "取消";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.Button2Click);
//
// textBox5
//
this.textBox5.Enabled = false;
this.textBox5.Font = new System.Drawing.Font("Times New Roman", 14.25F, Sys
tem.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
;
this.textBox5.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.textBox5.Location = new System.Drawing.Point(33, 192);
this.textBox5.Multiline = true;
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(449, 68);
this.textBox5.TabIndex = 12;
//
// dateTimePicker1
//
this.dateTimePicker1.Cursor = System.Windows.Forms.Cursors.SizeAll;
this.dateTimePicker1.Location = new System.Drawing.Point(33, 165);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(112, 21);
this.dateTimePicker1.TabIndex = 13;
//
// radioButton1
//
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(215, 83);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(43, 24);
this.radioButton1.TabIndex = 14;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "男";
this.radioButton1.UseVisualStyleBackColor = true;
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(326, 83);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(42, 24);
this.radioButton2.TabIndex = 15;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "女";
this.radioButton2.UseVisualStyleBackColor = true;
//
// comboBox1
//
this.comboBox1.Enabled = false;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
this.comboBox1.Location = new System.Drawing.Point(15, 31);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(102, 21);
this.comboBox1.TabIndex = 8;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(494, 283);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox1);
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.Text = "系统界面";
this.Load += new System.EventHandler(this.MainFormLoad);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
}
}
/*
* Created by SharpDevelop.
* User: lvchao335
* Date: 2007-8-26
* Time: 11:00
*
* To change this template use Tools | Options | Coding | Edit Standard Header
s.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace ddd
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm
{
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer su
pport.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button2Click(object sender, System.EventArgs e)
{
this.Close();
}
void Button1Click(object sender, System.EventArgs e)
{
if(textBox1.Text.Trim()==string.Empty)
textBox5.Text="姓名不能为空";
else if(textBox2.Text==string.Empty)
textBox5.Text="密码不能为空";
else if(textBox3.Text!=textBox2.Text)
textBox5.Text="确认密码与密码不符合";
else if((radioButton1.Text.Trim()==string.Empty)&&(radioButton2.Text.Trim()
==string.Empty))
textBox5.Text="性别不能为空";
else if(textBox4.Text.Trim()==string.Empty)
textBox5.Text="住址不能为空";
else
{
string user="姓名:"+textBox1.Text.Trim()+"
";
user=user+"性别:"+(radioButton1.Checked?"男":"女")+"
";
MessageBox.Show("注册成功","对话");
MessageBox.Show(user,"信息确认");
if(radioButton1.Checked==true)
{
Form1 f=new Form1();
f.Show();
}
if(radioButton2.Checked==true)
{
Form2 g=new Form2();
g.Show();
}
//this.Close();
//f.Close();
}
//comboBox1.Text="4";
}
void MainFormLoad(object sender, System.EventArgs e)
{
MessageBox.Show("您将进入系统界面","对话", MessageBoxButtons.OKCancel);
}
void TextBox1TextChanged(object sender, System.EventArgs e)
{
char []p=new char[textBox1.Text.Length];
p=textBox1.Text.ToCharArray();
if(textBox1.Text.Length!=0&&(p[textBox1.Text.Length-1]== 2 ))
textBox4.Focus();
}
void TextBox1_KeyPress(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode==Keys.Enter )
{
textBox3.Focus() ;
}
}
void TextBox2TextChanged(object sender, System.EventArgs e)
{
}
void TextBox3TextChanged(object sender, System.EventArgs e)
{
}
void TextBox5TextChanged(object sender, System.EventArgs e)
{
}
void FlowLayoutPanel1Paint(object sender, System.Windows.Forms.PaintEventArg
s e)
{
}
}
}
为什么总提示 No overload for TextBox1_KeyPress matches delegate System.Wind
ows.Forms.KeyPressEventHandler
--
http://www.taobao.com/view_image.php?pic=Wx0GGlFDXA1VVVRXWx0SCwkNGVxbVl8cVllcRgcaBwMSAF1QHABFWUZUXlxPXQEJAhwNCANfFl5fD0RRXQBRCkBbEAVSWhdLDw4BVwUICltLCzRcSlAABAscHxkU&title=y8nPwsvmye3M%2FQ%3D%3D&pCode=YzZjZTRiNTFjNjJhNmQ2NjVlNzM2OTlmOTQ1Mzc4NGU%3D&version=2
※ 来源:.吉林大学牡丹园站 bbs.jlu.edu.cn [FROM: 202.198.19.*]
※ 修改:.lvchaohehe 於 Aug 30 13:48:50 2007 修改本文.[FROM: 202.198.19.*]
|
|