如果在ListView中已经有记录了,我如何改变其中的一条记录的一个值啊?
   例如:
   学号  姓名
    1    张三
    2    李四
   如果我将“张三”改成“王五”应该怎么做啊?

解决方案 »

  1.   

    那要看你要修改那一列和那一行
    第一列第i行listview1.Items.Item[i].Caption:=''
    第二列第i行ListView1.Items.Item[i].SubItems.Strings[1];
    第3列第i行ListView1.Items.Item[i].SubItems.Strings[2];
    .........
      

  2.   

    那要看你要修改那一列和那一行
    第一列第i行listview1.Items.Item[i].Caption:=''
    第二列第i行ListView1.Items.Item[i].SubItems.Strings[1]:='';
    第3列第i行ListView1.Items.Item[i].SubItems.Strings[2]:='';
    .........
      

  3.   

    楼上说的是对的,但是在修改第二行的时候序数应该从零开始。因为第一行是Caption。也就是:ListView1.Items[i].Caption      := '';
    ListView1.Items[i].subItems[0]  := '';
    ListView1.Items[i].SubItemss[1] := '';
      

  4.   

    joseph2008说的对,但你的写法有误应为:
    ListView1.Items[i].Caption      := '';
    ListView1.Items[i].subItems.strings[0]  := '';
    ListView1.Items[i].SubItems.strings[1] := '';
      

  5.   

    我的没错,效果是一样的。TListItem的subItems就是一个tStrings类。下面是Delphi Visual Component Library Refrence Help 中的介绍,你可以看看。In Delphi, Strings is the default property of TStrings objects. The Strings identifier can be omitted when accessing the Strings property of a descendant of TStrings. For example, the following two lines of code are both acceptable and do the same thing:MyStrings.Strings[0] := 'This is the first string';MyStrings[0] := 'This is the first string';