读书人

listview 列怎么添加 array[0.600]of

发布时间: 2013-04-09 16:45:09 作者: rapoo

listview 列如何添加 array[0..600]of byte中数据?
这个数组数据为:010302050102030405060702030205010203040506070103020501020304050607010302050102030405060701030205010203040506070103020501020304050607。。。
我现在需要如何遍历这个数组
把绿色的显示在第一列
把红色的显示在第二列
第一列 第二列
1 01030205 01020304050607
2 02030205 01020304050607
3 01030205 01020304050607
4 04030205 01020304050607
5 01030205 01020304050607

。。。。
第一列的数据可能相同,也可能不同,第二列也是
请问大神如何做?
[解决办法]
两列数据各自长度相同么?
[解决办法]

引用:
引用:最简单的方法是用截取,最快速的方法是用复制内存
大神碰到一些简单的算法就会歇菜,求指教



这应该是你要的


procedure TForm1.Button1Click(Sender: TObject);
var
aItem: TListItem;
i, n, m: integer;
s1, s2: string;
a: array[0..600]of byte;
begin
s1 := '010302050102030405060702030205010203040506070103020501020304050607010302050102030405060701030205010203040506070103020501020304050607';
for i := 0 to Length(s1) - 1 do
a[i] := StrToInt(s1[i+1]);

i := 0;
n := Length('01030205');
s1 := '';
s2 := '';
m := 0;
while i < Length(a) do
begin
if m = 0 then
begin
if Length(s1) < n then
s1 := s1 + IntToStr(a[i])
else
begin
m := 1;
n := Length('01020304050607');
end;
end
else
begin
if Length(s2) < n then
s2 := s2 + IntToStr(a[i])
else
begin
aItem := ListView1.Items.add;//Show String TO ListView
aItem.Caption := s1;
aItem.SubItems.Add(s2);

//Clear Params
s1 := '';
s2 := '';
m := 0;
n := Length('01030205');
end;


end;

inc(i);
end;
if (s1 <> '') or (s2 <> '') then
begin
aItem := ListView1.Items.add;
aItem.Caption := s1;
aItem.SubItems.Add(s2);
end;
end;

读书人网 >.NET

热点推荐