delphi:with ListView .Items.Add do的意思

来源:百度知道 编辑:UC知道 时间:2024/05/29 00:09:59
with ListView.Items.Add do
begin
Caption:='Math';
subItems.add('m1');
subItems.add('m2');
subItems.add('m3');
end;
大家帮忙解释一下这段,特别是with ListView.Items.Add do这句的作用和意思,还有这句subItems.add('m1');subItems是啥?谢谢!希望尽量清楚点,呵呵!

with ListView.Items.Add do 执行ListView的添加动作
Caption是标题
subItems.add('m1'); 是添加名为“Math”下的子节点

同以下代码一样,只是不需要重复使用ListView.Items.Add
begin
ListView.Items.Add.Caption:='Math'; //增加父节点
ListView.Items.Add.subItems.add('m1'); //增加名为m1的子节点
ListView.Items.Add.subItems.add('m2');
ListView.Items.Add.subItems.add('m3');
end;