Delphi重要类的使用

 

 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  //可以赋值

 

转载于:https://www.cnblogs.com/wangvb2003/p/3748138.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值