📄 frmemployee.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace EmployeeForm
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class frmEmployee : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabMain;
private System.Windows.Forms.TabPage tabPersonal;
private System.Windows.Forms.TabPage tabProfessional;
private System.Windows.Forms.Label lblQual;
private System.Windows.Forms.Label lblWorkExp;
private System.Windows.Forms.TextBox txtQual;
private System.Windows.Forms.TextBox txtWorkExp;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnBack;
private System.Windows.Forms.Button btnDone;
private System.Windows.Forms.GroupBox grpGender;
private System.Windows.Forms.PictureBox picLogo;
private System.Windows.Forms.VScrollBar vsbPersonal;
private System.Windows.Forms.TextBox txtPhone;
private System.Windows.Forms.TextBox txtAdd;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.Label lblAddress;
private System.Windows.Forms.Label lblPhone;
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.RadioButton radFemale;
private System.Windows.Forms.RadioButton radMale;
private System.Windows.Forms.GroupBox grpGeneral;
private System.Windows.Forms.PictureBox picLogo2;
private System.ComponentModel.IContainer components;
private int oldValue;
private float vScrollMultiplier;
private float vAbsPos;
public frmEmployee()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
[STAThread]
static void Main()
{
Application.Run(new frmEmployee());
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmEmployee));
this.tabMain = new System.Windows.Forms.TabControl();
this.tabPersonal = new System.Windows.Forms.TabPage();
this.picLogo = new System.Windows.Forms.PictureBox();
this.btnNext = new System.Windows.Forms.Button();
this.grpGender = new System.Windows.Forms.GroupBox();
this.radFemale = new System.Windows.Forms.RadioButton();
this.radMale = new System.Windows.Forms.RadioButton();
this.grpGeneral = new System.Windows.Forms.GroupBox();
this.lblName = new System.Windows.Forms.Label();
this.lblAddress = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtAdd = new System.Windows.Forms.TextBox();
this.txtPhone = new System.Windows.Forms.TextBox();
this.lblPhone = new System.Windows.Forms.Label();
this.tabProfessional = new System.Windows.Forms.TabPage();
this.picLogo2 = new System.Windows.Forms.PictureBox();
this.btnDone = new System.Windows.Forms.Button();
this.btnBack = new System.Windows.Forms.Button();
this.txtWorkExp = new System.Windows.Forms.TextBox();
this.txtQual = new System.Windows.Forms.TextBox();
this.lblWorkExp = new System.Windows.Forms.Label();
this.lblQual = new System.Windows.Forms.Label();
this.vsbPersonal = new System.Windows.Forms.VScrollBar();
this.tabMain.SuspendLayout();
this.tabPersonal.SuspendLayout();
this.grpGender.SuspendLayout();
this.grpGeneral.SuspendLayout();
this.tabProfessional.SuspendLayout();
this.SuspendLayout();
//
// tabMain
//
this.tabMain.Controls.Add(this.tabPersonal);
this.tabMain.Controls.Add(this.tabProfessional);
this.tabMain.Location = new System.Drawing.Point(8, 8);
this.tabMain.Name = "tabMain";
this.tabMain.SelectedIndex = 0;
this.tabMain.Size = new System.Drawing.Size(368, 192);
this.tabMain.TabIndex = 0;
this.tabMain.Click += new System.EventHandler(this.tabMain_Click);
//
// tabPersonal
//
this.tabPersonal.BackColor = System.Drawing.SystemColors.Control;
this.tabPersonal.Controls.Add(this.picLogo);
this.tabPersonal.Controls.Add(this.btnNext);
this.tabPersonal.Controls.Add(this.grpGender);
this.tabPersonal.Controls.Add(this.grpGeneral);
this.tabPersonal.Location = new System.Drawing.Point(4, 22);
this.tabPersonal.Name = "tabPersonal";
this.tabPersonal.Size = new System.Drawing.Size(360, 166);
this.tabPersonal.TabIndex = 0;
this.tabPersonal.Text = "个人信息";
this.tabPersonal.Click += new System.EventHandler(this.tabPersonal_Click);
//
// picLogo
//
this.picLogo.Image = ((System.Drawing.Image)(resources.GetObject("picLogo.Image")));
this.picLogo.Location = new System.Drawing.Point(232, 22);
this.picLogo.Name = "picLogo";
this.picLogo.Size = new System.Drawing.Size(120, 128);
this.picLogo.TabIndex = 10;
this.picLogo.TabStop = false;
//
// btnNext
//
this.btnNext.Location = new System.Drawing.Point(160, 232);
this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(72, 23);
this.btnNext.TabIndex = 8;
this.btnNext.Text = "下一步(&N)";
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// grpGender
//
this.grpGender.Controls.Add(this.radFemale);
this.grpGender.Controls.Add(this.radMale);
this.grpGender.Location = new System.Drawing.Point(8, 168);
this.grpGender.Name = "grpGender";
this.grpGender.Size = new System.Drawing.Size(208, 56);
this.grpGender.TabIndex = 13;
this.grpGender.TabStop = false;
this.grpGender.Text = "性别";
//
// radFemale
//
this.radFemale.Location = new System.Drawing.Point(112, 16);
this.radFemale.Name = "radFemale";
this.radFemale.Size = new System.Drawing.Size(64, 24);
this.radFemale.TabIndex = 16;
this.radFemale.Text = "女";
//
// radMale
//
this.radMale.Location = new System.Drawing.Point(48, 16);
this.radMale.Name = "radMale";
this.radMale.Size = new System.Drawing.Size(56, 24);
this.radMale.TabIndex = 15;
this.radMale.Text = "男";
//
// grpGeneral
//
this.grpGeneral.Controls.Add(this.lblName);
this.grpGeneral.Controls.Add(this.lblAddress);
this.grpGeneral.Controls.Add(this.txtName);
this.grpGeneral.Controls.Add(this.txtAdd);
this.grpGeneral.Controls.Add(this.txtPhone);
this.grpGeneral.Controls.Add(this.lblPhone);
this.grpGeneral.Location = new System.Drawing.Point(8, 8);
this.grpGeneral.Name = "grpGeneral";
this.grpGeneral.Size = new System.Drawing.Size(208, 152);
this.grpGeneral.TabIndex = 14;
this.grpGeneral.TabStop = false;
this.grpGeneral.Text = "一般信息";
//
// lblName
//
this.lblName.Location = new System.Drawing.Point(8, 16);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(56, 23);
this.lblName.TabIndex = 15;
this.lblName.Text = "姓名:";
//
// lblAddress
//
this.lblAddress.Location = new System.Drawing.Point(8, 56);
this.lblAddress.Name = "lblAddress";
this.lblAddress.Size = new System.Drawing.Size(48, 23);
this.lblAddress.TabIndex = 17;
this.lblAddress.Text = "住址:";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(64, 16);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(120, 21);
this.txtName.TabIndex = 19;
this.txtName.Text = "";
//
// txtAdd
//
this.txtAdd.Location = new System.Drawing.Point(64, 56);
this.txtAdd.Multiline = true;
this.txtAdd.Name = "txtAdd";
this.txtAdd.Size = new System.Drawing.Size(120, 40);
this.txtAdd.TabIndex = 20;
this.txtAdd.Text = "";
//
// txtPhone
//
this.txtPhone.Location = new System.Drawing.Point(64, 112);
this.txtPhone.Name = "txtPhone";
this.txtPhone.Size = new System.Drawing.Size(120, 21);
this.txtPhone.TabIndex = 21;
this.txtPhone.Text = "";
//
// lblPhone
//
this.lblPhone.Location = new System.Drawing.Point(6, 112);
this.lblPhone.Name = "lblPhone";
this.lblPhone.Size = new System.Drawing.Size(72, 23);
this.lblPhone.TabIndex = 16;
this.lblPhone.Text = "电话号码:";
//
// tabProfessional
//
this.tabProfessional.Controls.Add(this.picLogo2);
this.tabProfessional.Controls.Add(this.btnDone);
this.tabProfessional.Controls.Add(this.btnBack);
this.tabProfessional.Controls.Add(this.txtWorkExp);
this.tabProfessional.Controls.Add(this.txtQual);
this.tabProfessional.Controls.Add(this.lblWorkExp);
this.tabProfessional.Controls.Add(this.lblQual);
this.tabProfessional.Location = new System.Drawing.Point(4, 22);
this.tabProfessional.Name = "tabProfessional";
this.tabProfessional.Size = new System.Drawing.Size(360, 166);
this.tabProfessional.TabIndex = 1;
this.tabProfessional.Text = "职员信息";
//
// picLogo2
//
this.picLogo2.Image = ((System.Drawing.Image)(resources.GetObject("picLogo2.Image")));
this.picLogo2.Location = new System.Drawing.Point(248, 8);
this.picLogo2.Name = "picLogo2";
this.picLogo2.Size = new System.Drawing.Size(104, 128);
this.picLogo2.TabIndex = 11;
this.picLogo2.TabStop = false;
//
// btnDone
//
this.btnDone.Location = new System.Drawing.Point(168, 113);
this.btnDone.Name = "btnDone";
this.btnDone.Size = new System.Drawing.Size(72, 23);
this.btnDone.TabIndex = 5;
this.btnDone.Text = "完成(&D)";
this.btnDone.Click += new System.EventHandler(this.btnDone_Click);
//
// btnBack
//
this.btnBack.Location = new System.Drawing.Point(72, 113);
this.btnBack.Name = "btnBack";
this.btnBack.Size = new System.Drawing.Size(72, 23);
this.btnBack.TabIndex = 4;
this.btnBack.Text = "上一步(&B)";
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
//
// txtWorkExp
//
this.txtWorkExp.Location = new System.Drawing.Point(140, 48);
this.txtWorkExp.Name = "txtWorkExp";
this.txtWorkExp.TabIndex = 3;
this.txtWorkExp.Text = "";
//
// txtQual
//
this.txtQual.Location = new System.Drawing.Point(140, 16);
this.txtQual.Name = "txtQual";
this.txtQual.TabIndex = 2;
this.txtQual.Text = "";
//
// lblWorkExp
//
this.lblWorkExp.Location = new System.Drawing.Point(8, 48);
this.lblWorkExp.Name = "lblWorkExp";
this.lblWorkExp.Size = new System.Drawing.Size(144, 23);
this.lblWorkExp.TabIndex = 1;
this.lblWorkExp.Text = "工作经验(年):";
this.lblWorkExp.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblQual
//
this.lblQual.Location = new System.Drawing.Point(8, 16);
this.lblQual.Name = "lblQual";
this.lblQual.Size = new System.Drawing.Size(144, 23);
this.lblQual.TabIndex = 0;
this.lblQual.Text = "输入资格证书:";
//
// vsbPersonal
//
this.vsbPersonal.Location = new System.Drawing.Point(384, 22);
this.vsbPersonal.Name = "vsbPersonal";
this.vsbPersonal.Size = new System.Drawing.Size(16, 178);
this.vsbPersonal.SmallChange = 3;
this.vsbPersonal.TabIndex = 1;
this.vsbPersonal.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vsbPersonal_Scroll);
//
// frmEmployee
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(408, 213);
this.Controls.Add(this.tabMain);
this.Controls.Add(this.vsbPersonal);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.Name = "frmEmployee";
this.Text = "职员申请表";
this.tabMain.ResumeLayout(false);
this.tabPersonal.ResumeLayout(false);
this.grpGender.ResumeLayout(false);
this.grpGeneral.ResumeLayout(false);
this.tabProfessional.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnNext_Click(object sender, System.EventArgs e)
{
if (tabMain.SelectedIndex ==0)
{
vsbPersonal.Visible =false;
tabMain.SelectedIndex = 1;
}
}
private void btnBack_Click(object sender, System.EventArgs e)
{
if (tabMain.SelectedIndex ==1)
{
vsbPersonal.Visible = true;
tabMain.SelectedIndex = 0;
}
}
private void btnDone_Click(object sender, System.EventArgs e)
{
MessageBox.Show("感谢您输入信息","信息");
Application.Exit();
}
private void vsbPersonal_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
vAbsPos = (float)(vsbPersonal.Value - vsbPersonal.Minimum);
SetVerticalScrollMultiplier(grpGeneral);
//检查滚动的方向是自上往下还是自下往上
if (vsbPersonal.Value > oldValue)
{
grpGeneral.Top = grpGeneral.Top- (int)(vScrollMultiplier * vAbsPos);
picLogo.Top = picLogo.Top- (int)(vScrollMultiplier * vAbsPos);
grpGender.Top = grpGender.Top- (int)(vScrollMultiplier * vAbsPos);
btnNext.Top = btnNext.Top- (int)(vScrollMultiplier * vAbsPos);
}
else
if (vsbPersonal.Value < oldValue)
{
grpGeneral.Top = grpGeneral.Top + (int)(vScrollMultiplier * vAbsPos);
picLogo.Top = picLogo.Top + (int)(vScrollMultiplier * vAbsPos);
grpGender.Top = grpGender.Top + (int)(vScrollMultiplier * vAbsPos);
btnNext.Top = btnNext.Top + (int)(vScrollMultiplier * vAbsPos);
}
oldValue = vsbPersonal.Value;
}
private void SetVerticalScrollMultiplier(Control ctrl)
{
float hsb = (float)(vsbPersonal.Height - ctrl.Height);
float ticks = (float)(vsbPersonal.Maximum - vsbPersonal.Minimum);
vScrollMultiplier = hsb / ticks;
}
private void tabMain_Click(object sender, System.EventArgs e)
{
if (tabMain.SelectedIndex ==0)
{
vsbPersonal.Visible =false;
tabMain.SelectedIndex = 1;
}
else if (tabMain.SelectedIndex ==1)
{
vsbPersonal.Visible = true;
tabMain.SelectedIndex = 0;
}
}
private void btnExit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void tabPersonal_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -