📄 winform.pas.~4~
字号:
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;
ComboBox1: System.Windows.Forms.ComboBox;
TreeView1: System.Windows.Forms.TreeView;
ListView1: System.Windows.Forms.ListView;
Label1: System.Windows.Forms.Label;
Label2: System.Windows.Forms.Label;
TextBox1: System.Windows.Forms.TextBox;
Label3: System.Windows.Forms.Label;
Label4: System.Windows.Forms.Label;
Button1: System.Windows.Forms.Button;
Button2: System.Windows.Forms.Button;
Button3: System.Windows.Forms.Button;
Button4: System.Windows.Forms.Button;
CheckBox1: System.Windows.Forms.CheckBox;
Label5: System.Windows.Forms.Label;
Button5: System.Windows.Forms.Button;
TextBox2: System.Windows.Forms.TextBox;
ColumnHeader1: System.Windows.Forms.ColumnHeader;
ColumnHeader2: System.Windows.Forms.ColumnHeader;
CheckBox2: System.Windows.Forms.CheckBox;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure CheckBox2_CheckedChanged(sender: System.Object; e: System.EventArgs);
procedure CheckBox1_CheckedChanged(sender: System.Object; e: System.EventArgs);
procedure Button1_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
TArrayOfString = array of string;
TArrayOfSystem_Object = array of System.Object;
TArrayOfSystem_Windows_Forms_ColumnHeader = array of System.Windows.Forms.ColumnHeader;
TArrayOfSystem_Windows_Forms_ListViewItem = array of System.Windows.Forms.ListViewItem;
var
ListViewItem13: System.Windows.Forms.ListViewItem;
ListViewItem12: System.Windows.Forms.ListViewItem;
ListViewItem11: System.Windows.Forms.ListViewItem;
begin
ListViewItem11 := System.Windows.Forms.ListViewItem.Create(TArrayOfString.Create('张' +
'艳玲', '工程学院'), -1);
ListViewItem12 := System.Windows.Forms.ListViewItem.Create(TArrayOfString.Create('张' +
'健', '信息学院'), -1);
ListViewItem13 := System.Windows.Forms.ListViewItem.Create(TArrayOfString.Create('赵' +
'文静', '法学院'), -1);
Self.ComboBox1 := System.Windows.Forms.ComboBox.Create;
Self.TreeView1 := System.Windows.Forms.TreeView.Create;
Self.ListView1 := System.Windows.Forms.ListView.Create;
Self.ColumnHeader1 := System.Windows.Forms.ColumnHeader.Create;
Self.ColumnHeader2 := System.Windows.Forms.ColumnHeader.Create;
Self.Label1 := System.Windows.Forms.Label.Create;
Self.Label2 := System.Windows.Forms.Label.Create;
Self.TextBox1 := System.Windows.Forms.TextBox.Create;
Self.Label3 := System.Windows.Forms.Label.Create;
Self.Label4 := System.Windows.Forms.Label.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.Button2 := System.Windows.Forms.Button.Create;
Self.Button3 := System.Windows.Forms.Button.Create;
Self.Button4 := System.Windows.Forms.Button.Create;
Self.CheckBox1 := System.Windows.Forms.CheckBox.Create;
Self.Label5 := System.Windows.Forms.Label.Create;
Self.Button5 := System.Windows.Forms.Button.Create;
Self.TextBox2 := System.Windows.Forms.TextBox.Create;
Self.CheckBox2 := System.Windows.Forms.CheckBox.Create;
Self.SuspendLayout;
//
// ComboBox1
//
Self.ComboBox1.Items.AddRange(TArrayOfSystem_Object.Create('软件学院', '人文学院',
'管理学院', '法学院', '外国语学院', '理学院'));
Self.ComboBox1.Location := System.Drawing.Point.Create(48, 88);
Self.ComboBox1.Name := 'ComboBox1';
Self.ComboBox1.Size := System.Drawing.Size.Create(121, 20);
Self.ComboBox1.TabIndex := 1;
Self.ComboBox1.Text := '选择院系';
//
// TreeView1
//
Self.TreeView1.ImageIndex := -1;
Self.TreeView1.Location := System.Drawing.Point.Create(184, 192);
Self.TreeView1.Name := 'TreeView1';
Self.TreeView1.SelectedImageIndex := -1;
Self.TreeView1.Size := System.Drawing.Size.Create(232, 144);
Self.TreeView1.TabIndex := 3;
//
// ListView1
//
Self.ListView1.Columns.AddRange(TArrayOfSystem_Windows_Forms_ColumnHeader.Create(Self.ColumnHeader1,
Self.ColumnHeader2));
Self.ListView1.Items.AddRange(TArrayOfSystem_Windows_Forms_ListViewItem.Create(ListViewItem11,
ListViewItem12, ListViewItem13));
Self.ListView1.Location := System.Drawing.Point.Create(184, 32);
Self.ListView1.Name := 'ListView1';
Self.ListView1.Size := System.Drawing.Size.Create(232, 112);
Self.ListView1.TabIndex := 4;
Self.ListView1.View := System.Windows.Forms.View.Details;
//
// ColumnHeader1
//
Self.ColumnHeader1.Text := '姓名';
//
// ColumnHeader2
//
Self.ColumnHeader2.Text := '院系';
//
// Label1
//
Self.Label1.Location := System.Drawing.Point.Create(8, 32);
Self.Label1.Name := 'Label1';
Self.Label1.Size := System.Drawing.Size.Create(32, 16);
Self.Label1.TabIndex := 5;
Self.Label1.Text := '姓名';
//
// Label2
//
Self.Label2.Location := System.Drawing.Point.Create(8, 88);
Self.Label2.Name := 'Label2';
Self.Label2.Size := System.Drawing.Size.Create(32, 16);
Self.Label2.TabIndex := 6;
Self.Label2.Text := '院系';
//
// TextBox1
//
Self.TextBox1.Location := System.Drawing.Point.Create(48, 32);
Self.TextBox1.Name := 'TextBox1';
Self.TextBox1.Size := System.Drawing.Size.Create(121, 21);
Self.TextBox1.TabIndex := 7;
Self.TextBox1.Text := '';
//
// Label3
//
Self.Label3.Location := System.Drawing.Point.Create(200, 8);
Self.Label3.Name := 'Label3';
Self.Label3.Size := System.Drawing.Size.Create(64, 16);
Self.Label3.TabIndex := 8;
Self.Label3.Text := '学生列表';
//
// Label4
//
Self.Label4.Location := System.Drawing.Point.Create(200, 168);
Self.Label4.Name := 'Label4';
Self.Label4.Size := System.Drawing.Size.Create(64, 16);
Self.Label4.TabIndex := 9;
Self.Label4.Text := '院系结构';
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(16, 128);
Self.Button1.Name := 'Button1';
Self.Button1.Size := System.Drawing.Size.Create(64, 23);
Self.Button1.TabIndex := 10;
Self.Button1.Text := '添加';
Include(Self.Button1.Click, Self.Button1_Click);
//
// Button2
//
Self.Button2.Location := System.Drawing.Point.Create(104, 128);
Self.Button2.Name := 'Button2';
Self.Button2.Size := System.Drawing.Size.Create(64, 23);
Self.Button2.TabIndex := 11;
Self.Button2.Text := '删除';
//
// Button3
//
Self.Button3.Location := System.Drawing.Point.Create(104, 240);
Self.Button3.Name := 'Button3';
Self.Button3.Size := System.Drawing.Size.Create(64, 23);
Self.Button3.TabIndex := 13;
Self.Button3.Text := '删除';
//
// Button4
//
Self.Button4.Location := System.Drawing.Point.Create(16, 240);
Self.Button4.Name := 'Button4';
Self.Button4.Size := System.Drawing.Size.Create(64, 23);
Self.Button4.TabIndex := 12;
Self.Button4.Text := '添加';
//
// CheckBox1
//
Self.CheckBox1.AllowDrop := True;
Self.CheckBox1.Location := System.Drawing.Point.Create(280, 160);
Self.CheckBox1.Name := 'CheckBox1';
Self.CheckBox1.Size := System.Drawing.Size.Create(80, 24);
Self.CheckBox1.TabIndex := 14;
Self.CheckBox1.Text := '带复选框';
Include(Self.CheckBox1.CheckedChanged, Self.CheckBox1_CheckedChanged);
//
// Label5
//
Self.Label5.Location := System.Drawing.Point.Create(8, 200);
Self.Label5.Name := 'Label5';
Self.Label5.Size := System.Drawing.Size.Create(32, 16);
Self.Label5.TabIndex := 16;
Self.Label5.Text := '院系';
//
// Button5
//
Self.Button5.Location := System.Drawing.Point.Create(56, 304);
Self.Button5.Name := 'Button5';
Self.Button5.TabIndex := 17;
Self.Button5.Text := '退出';
//
// TextBox2
//
Self.TextBox2.Location := System.Drawing.Point.Create(48, 200);
Self.TextBox2.Name := 'TextBox2';
Self.TextBox2.Size := System.Drawing.Size.Create(121, 21);
Self.TextBox2.TabIndex := 18;
Self.TextBox2.Text := '';
//
// CheckBox2
//
Self.CheckBox2.AllowDrop := True;
Self.CheckBox2.Location := System.Drawing.Point.Create(280, 0);
Self.CheckBox2.Name := 'CheckBox2';
Self.CheckBox2.Size := System.Drawing.Size.Create(80, 32);
Self.CheckBox2.TabIndex := 19;
Self.CheckBox2.Text := '带复选框';
Include(Self.CheckBox2.CheckedChanged, Self.CheckBox2_CheckedChanged);
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
Self.ClientSize := System.Drawing.Size.Create(424, 349);
Self.Controls.Add(Self.CheckBox2);
Self.Controls.Add(Self.TextBox2);
Self.Controls.Add(Self.TextBox1);
Self.Controls.Add(Self.Button5);
Self.Controls.Add(Self.Label5);
Self.Controls.Add(Self.CheckBox1);
Self.Controls.Add(Self.Button3);
Self.Controls.Add(Self.Button4);
Self.Controls.Add(Self.Button2);
Self.Controls.Add(Self.Button1);
Self.Controls.Add(Self.Label4);
Self.Controls.Add(Self.Label3);
Self.Controls.Add(Self.Label2);
Self.Controls.Add(Self.Label1);
Self.Controls.Add(Self.ListView1);
Self.Controls.Add(Self.TreeView1);
Self.Controls.Add(Self.ComboBox1);
Self.Name := 'TWinForm';
Self.Text := '学生信息';
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;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
type
strarray= array of string;
ArrayOfListViewItem = array of ListViewItem;
var
str : strarray;
ListViewItem13: System.Windows.Forms.ListViewItem;
ListViewItem12: System.Windows.Forms.ListViewItem;
ListViewItem11: System.Windows.Forms.ListViewItem;
begin
if TExtBox1.Text ='' then
MessageBox.Show('请输入学生姓名')
else
begin
MessageBox.Show(ComboBox1.text) ;
ListViewItem11 :=ListviewItem.Create(strarray.Create(Textbox1.text,ComboBox1.Text));
ListView1.Items.AddRange(ArrayOfListViewItem.create(ListViewItem11));
end;
end;
procedure TWinForm.CheckBox1_CheckedChanged(sender: System.Object; e: System.EventArgs);
begin
TreeView1.CheckBoxes :=CheckBox1.Checked ;
end;
procedure TWinForm.CheckBox2_CheckedChanged(sender: System.Object; e: System.EventArgs);
begin
ListView1.CheckBoxes:= CheckBox2.Checked ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -