1
1、TstringList类
2
3 List:=TStringList.Create;
4 List.Add( ' str1 ')
5 List.Add( ' str2 ')
6 List.Exchange( 0, 1) 置换
7 List.Insert( 0, ' str3 ') 插入
8 i:=list.Indexof( ' str2 '); //第一次出现的序号
9 List.sort //排序
10 List.Sorted:=true //设定排序
11 List.Count // 总数
12 List.Text //内容 每一项用# 13 # 10分开
13 List.Delete( 0);
14 List.LoadFormFile( ' c:\tmp.txt ');
15 List.SaveTofile( ' c:\tmp.txt ');
16 List.Clear;
17 List.Free;
18 List[ 0] 返回第一项字符串
19 List.ComaText= ' aaa,bbb,ccc ' ; //相当于List里添加了aaa bbb ccc 三项
20 相当于
21 List.text:= ' aaa '+# 13+# 10+ ' bbb '+# 13+# 10+ ' ccc '
22 List.Delimter:= ' | ' //置换分隔符
23 List.DelimtedTexted:= ' aaa|bbb|ccc '; //添加三项
24
25 List.BeginUpdate
26 List.EndUpdate
27
28 ListBox的AddObject用法
29 BtnList:=TstringList.Create;
30 BtnList.Addobject( '',Button1)
31 BtnList.Addobjecc( '',Button2)
32 Tbutton(BtnList.objects[i]).Onclick:=btnclick
33
34 ComboBox1.Items.addobject( ' vsIcon ',Tobject(vsIcon));
35 combobox1.Items.addobject( ' vsList ',Tobject(vsList));
36 combobox1.Items.addobject( ' vssmallIcon ',Tobject(vssmallIcon));
37 combobox1.Items.addobject( ' vsReport ',Tobject(vsReport));
38 { 可以将普通变量转为Tobject指针形式,调用如下代码 }
39
40 with combobox1 do
41 Listview1.viewstyle:=TviewStyle(items.objects[itemindex]);
42
43
44 类似于字典的操作
45 List.clear;
46 List.Add( ' AAA=111 ');
47 List.Add( ' bbb=222 ');
48 List.Add( ' ccc=333 ');
49 List.Names[ 1] ; //bbb
50 List.ValuefromIndex[ 1] // 222
51 List.Values[ ' bbb '] // 222
52 List.ValueFromIndex[ 1]:= 333 //可以赋值
2
3 List:=TStringList.Create;
4 List.Add( ' str1 ')
5 List.Add( ' str2 ')
6 List.Exchange( 0, 1) 置换
7 List.Insert( 0, ' str3 ') 插入
8 i:=list.Indexof( ' str2 '); //第一次出现的序号
9 List.sort //排序
10 List.Sorted:=true //设定排序
11 List.Count // 总数
12 List.Text //内容 每一项用# 13 # 10分开
13 List.Delete( 0);
14 List.LoadFormFile( ' c:\tmp.txt ');
15 List.SaveTofile( ' c:\tmp.txt ');
16 List.Clear;
17 List.Free;
18 List[ 0] 返回第一项字符串
19 List.ComaText= ' aaa,bbb,ccc ' ; //相当于List里添加了aaa bbb ccc 三项
20 相当于
21 List.text:= ' aaa '+# 13+# 10+ ' bbb '+# 13+# 10+ ' ccc '
22 List.Delimter:= ' | ' //置换分隔符
23 List.DelimtedTexted:= ' aaa|bbb|ccc '; //添加三项
24
25 List.BeginUpdate
26 List.EndUpdate
27
28 ListBox的AddObject用法
29 BtnList:=TstringList.Create;
30 BtnList.Addobject( '',Button1)
31 BtnList.Addobjecc( '',Button2)
32 Tbutton(BtnList.objects[i]).Onclick:=btnclick
33
34 ComboBox1.Items.addobject( ' vsIcon ',Tobject(vsIcon));
35 combobox1.Items.addobject( ' vsList ',Tobject(vsList));
36 combobox1.Items.addobject( ' vssmallIcon ',Tobject(vssmallIcon));
37 combobox1.Items.addobject( ' vsReport ',Tobject(vsReport));
38 { 可以将普通变量转为Tobject指针形式,调用如下代码 }
39
40 with combobox1 do
41 Listview1.viewstyle:=TviewStyle(items.objects[itemindex]);
42
43
44 类似于字典的操作
45 List.clear;
46 List.Add( ' AAA=111 ');
47 List.Add( ' bbb=222 ');
48 List.Add( ' ccc=333 ');
49 List.Names[ 1] ; //bbb
50 List.ValuefromIndex[ 1] // 222
51 List.Values[ ' bbb '] // 222
52 List.ValueFromIndex[ 1]:= 333 //可以赋值