📄 winform.pas.~5~
字号:
unit WinForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
TabControl1: System.Windows.Forms.TabControl;
TabPage1: System.Windows.Forms.TabPage;
TabPage2: System.Windows.Forms.TabPage;
ListBox1: System.Windows.Forms.ListBox;
CheckedListBox1: System.Windows.Forms.CheckedListBox;
Button1: System.Windows.Forms.Button;
Button2: System.Windows.Forms.Button;
Label1: System.Windows.Forms.Label;
Label2: System.Windows.Forms.Label;
TextBox1: System.Windows.Forms.TextBox;
TextBox2: System.Windows.Forms.TextBox;
Button3: System.Windows.Forms.Button;
Button4: System.Windows.Forms.Button;
Label3: System.Windows.Forms.Label;
Label4: System.Windows.Forms.Label;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button3_Click(sender: System.Object; e: System.EventArgs);
procedure Button4_Click(sender: System.Object; e: System.EventArgs);
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
procedure Button2_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
implementation
{$AUTOBOX ON}
{$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>
procedure TWinForm.InitializeComponent;
type
TArrayOfSystem_Object = array of System.Object;
begin
Self.TabControl1 := System.Windows.Forms.TabControl.Create;
Self.TabPage1 := System.Windows.Forms.TabPage.Create;
Self.Button4 := System.Windows.Forms.Button.Create;
Self.Button3 := System.Windows.Forms.Button.Create;
Self.TextBox2 := System.Windows.Forms.TextBox.Create;
Self.TextBox1 := System.Windows.Forms.TextBox.Create;
Self.Label2 := System.Windows.Forms.Label.Create;
Self.Label1 := System.Windows.Forms.Label.Create;
Self.TabPage2 := System.Windows.Forms.TabPage.Create;
Self.Label4 := System.Windows.Forms.Label.Create;
Self.Label3 := System.Windows.Forms.Label.Create;
Self.CheckedListBox1 := System.Windows.Forms.CheckedListBox.Create;
Self.ListBox1 := System.Windows.Forms.ListBox.Create;
Self.Button2 := System.Windows.Forms.Button.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.TabControl1.SuspendLayout;
Self.TabPage1.SuspendLayout;
Self.TabPage2.SuspendLayout;
Self.SuspendLayout;
//
// TabControl1
//
Self.TabControl1.Controls.Add(Self.TabPage1);
Self.TabControl1.Controls.Add(Self.TabPage2);
Self.TabControl1.Location := System.Drawing.Point.Create(16, 16);
Self.TabControl1.Name := 'TabControl1';
Self.TabControl1.SelectedIndex := 0;
Self.TabControl1.Size := System.Drawing.Size.Create(360, 240);
Self.TabControl1.TabIndex := 0;
//
// TabPage1
//
Self.TabPage1.Controls.Add(Self.Button4);
Self.TabPage1.Controls.Add(Self.Button3);
Self.TabPage1.Controls.Add(Self.TextBox2);
Self.TabPage1.Controls.Add(Self.TextBox1);
Self.TabPage1.Controls.Add(Self.Label2);
Self.TabPage1.Controls.Add(Self.Label1);
Self.TabPage1.Location := System.Drawing.Point.Create(4, 21);
Self.TabPage1.Name := 'TabPage1';
Self.TabPage1.Size := System.Drawing.Size.Create(352, 215);
Self.TabPage1.TabIndex := 0;
Self.TabPage1.Text := '登录';
//
// Button4
//
Self.Button4.Location := System.Drawing.Point.Create(184, 144);
Self.Button4.Name := 'Button4';
Self.Button4.TabIndex := 5;
Self.Button4.Text := '退出';
Include(Self.Button4.Click, Self.Button4_Click);
//
// Button3
//
Self.Button3.Location := System.Drawing.Point.Create(80, 144);
Self.Button3.Name := 'Button3';
Self.Button3.TabIndex := 4;
Self.Button3.Text := '登录';
Include(Self.Button3.Click, Self.Button3_Click);
//
// TextBox2
//
Self.TextBox2.Location := System.Drawing.Point.Create(144, 88);
Self.TextBox2.Name := 'TextBox2';
Self.TextBox2.PasswordChar := '*';
Self.TextBox2.Size := System.Drawing.Size.Create(128, 21);
Self.TextBox2.TabIndex := 3;
Self.TextBox2.Text := '';
//
// TextBox1
//
Self.TextBox1.Location := System.Drawing.Point.Create(144, 48);
Self.TextBox1.Name := 'TextBox1';
Self.TextBox1.Size := System.Drawing.Size.Create(128, 21);
Self.TextBox1.TabIndex := 2;
Self.TextBox1.Text := '';
//
// Label2
//
Self.Label2.Location := System.Drawing.Point.Create(64, 88);
Self.Label2.Name := 'Label2';
Self.Label2.Size := System.Drawing.Size.Create(48, 23);
Self.Label2.TabIndex := 1;
Self.Label2.Text := '密码';
//
// Label1
//
Self.Label1.Location := System.Drawing.Point.Create(64, 48);
Self.Label1.Name := 'Label1';
Self.Label1.Size := System.Drawing.Size.Create(48, 23);
Self.Label1.TabIndex := 0;
Self.Label1.Text := '用户名';
//
// TabPage2
//
Self.TabPage2.Controls.Add(Self.Label4);
Self.TabPage2.Controls.Add(Self.Label3);
Self.TabPage2.Controls.Add(Self.CheckedListBox1);
Self.TabPage2.Controls.Add(Self.ListBox1);
Self.TabPage2.Controls.Add(Self.Button2);
Self.TabPage2.Controls.Add(Self.Button1);
Self.TabPage2.Location := System.Drawing.Point.Create(4, 21);
Self.TabPage2.Name := 'TabPage2';
Self.TabPage2.Size := System.Drawing.Size.Create(352, 215);
Self.TabPage2.TabIndex := 1;
Self.TabPage2.Text := '选课';
//
// Label4
//
Self.Label4.Location := System.Drawing.Point.Create(208, 16);
Self.Label4.Name := 'Label4';
Self.Label4.Size := System.Drawing.Size.Create(64, 16);
Self.Label4.TabIndex := 5;
Self.Label4.Text := '已选课程';
//
// Label3
//
Self.Label3.Location := System.Drawing.Point.Create(16, 16);
Self.Label3.Name := 'Label3';
Self.Label3.Size := System.Drawing.Size.Create(72, 16);
Self.Label3.TabIndex := 4;
Self.Label3.Text := '所有课程';
//
// CheckedListBox1
//
Self.CheckedListBox1.Items.AddRange(TArrayOfSystem_Object.Create('数据挖掘', '计' +
'算机基础', '大学英语', 'Delphi 2005程序设计教程', '军事理论', 'Visual C++.NET', '法律原理',
'数字电路', '经济学原理', '经济学基础', '精通Flash MX 2004', '信号处理'));
Self.CheckedListBox1.Location := System.Drawing.Point.Create(16, 40);
Self.CheckedListBox1.Name := 'CheckedListBox1';
Self.CheckedListBox1.Size := System.Drawing.Size.Create(120, 164);
Self.CheckedListBox1.TabIndex := 1;
//
// ListBox1
//
Self.ListBox1.ItemHeight := 12;
Self.ListBox1.Location := System.Drawing.Point.Create(208, 40);
Self.ListBox1.Name := 'ListBox1';
Self.ListBox1.Size := System.Drawing.Size.Create(128, 160);
Self.ListBox1.TabIndex := 0;
//
// Button2
//
Self.Button2.Location := System.Drawing.Point.Create(152, 120);
Self.Button2.Name := 'Button2';
Self.Button2.Size := System.Drawing.Size.Create(40, 23);
Self.Button2.TabIndex := 3;
Self.Button2.Text := '<<';
Include(Self.Button2.Click, Self.Button2_Click);
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(152, 64);
Self.Button1.Name := 'Button1';
Self.Button1.Size := System.Drawing.Size.Create(40, 23);
Self.Button1.TabIndex := 2;
Self.Button1.Text := '>>';
Include(Self.Button1.Click, Self.Button1_Click);
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(392, 269);
Self.Controls.Add(Self.TabControl1);
Self.Name := 'TWinForm';
Self.Text := '选课';
Self.TabControl1.ResumeLayout(False);
Self.TabPage1.ResumeLayout(False);
Self.TabPage2.ResumeLayout(False);
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
TabControl1.Controls.Remove(TabPage2);
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure TWinForm.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
if ListBox1.SelectedIndex >=0 then
ListBox1.Items.Remove(ListBox1.SelectedItem )
end;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
IF CheckedListBox1.SelectedIndex>=0 then
begin
if ListBox1.FindString(CheckedListBox1.SelectedItem.ToString)<>-1 then
MessageBox.Show ('你已经选了这门课')
else
Listbox1.Items.Add(CheckedListBox1.SelectedItem) ;
end;
end;
procedure TWinForm.Button4_Click(sender: System.Object; e: System.EventArgs);
begin
Close;
end;
procedure TWinForm.Button3_Click(sender: System.Object; e: System.EventArgs);
begin
if TextBox1.Text = '' then
MessageBox.Show ('请输入用户名')
else if TextBox2.Text = '' then
MessageBox.Show ('请输入密码')
else if (TextBox1.Text <>'zhaoyanduo' )or (TextBox2.Text <> 'author' )then
MessageBox.Show ('用户名密码错误')
else
begin
Tabcontrol1.Controls.Add(TabPage2);
TabControl1.SelectedTab :=TabPage2;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -