TListBox
# TListBox 列表
列表主要逐行显示,可以选择
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add('添加一行');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox1.DeleteSelected;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ListBox1.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
ListBox1.Items.Delete(2); //这里的2,就是第三行,因为编号是从0开始的
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
ListBox1.Items.LoadFromFile('s.txt');
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
ListBox1.Items.SaveToFile('m.txt');
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Form1.Caption := ListBox1.Items[ListBox1.ItemIndex];
end;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 补充