Unit1.pas
资源名称:xiaobai.rar [点击查看]
上传用户:autowell
上传日期:2022-06-21
资源大小:16754k
文件大小:2k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ComCtrls;
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Button1: TButton;
- Edit1: TEdit;
- Button2: TButton;
- ComboBox1: TComboBox;
- TreeView1: TTreeView;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure TreeView1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- ListBox1.Items.Add(edit1.Text); //使用Add方法向列表框增加项目
- //ListBox1.Items.Add('北京');
- //ListBox1.Items.Add('河北');
- //ListBox1.Items.Add('河南');
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- ListBox1.Items.Delete (ListBox1.ItemIndex)
- //ListBox1.Clear
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- ListBox1.Items.Add('山西'); //使用Add方法向列表框增加项目
- ListBox1.Items.Add('北京');
- ListBox1.Items.Add('河北');
- ListBox1.Items.Add('河南');
- ListBox1.Items.Add('湖南');
- ListBox1.Items.Add('内蒙古');
- end;
- procedure TForm1.TreeView1Click(Sender: TObject);
- begin
- edit1.Text:=TreeView1. Selected.Text;
- //if TreeView1.items[1].Selected then edit1.Text:=TreeView1.items[1].Text
- //else if TreeView1.items[2].Selected then edit1.Text:=TreeView1.items[2].Text
- end;
- end.