我手头的教材没有,又没查到,请帮忙~

解决方案 »

  1.   

    In TStringListCapacity
    CaseSensitive
    Count
    Duplicates
    Objects
    Sorted
    StringsDerived from TStringsCommaText
    DelimitedText
    Delimiter
    Names
    QuoteChar
    StringsAdapter
    Text
    ValuesIn TStringListAdd
    AddObject
    Clear
    CustomSort
    Delete
    Destroy
    Exchange
    Find
    IndexOf
    Insert
    InsertObject
    SortDerived from TStringsAddStrings
    Append
    Assign
    BeginUpdate
    EndUpdate
    Equals
    GetText
    IndexOfName
    IndexOfObject
    LoadFromFile
    LoadFromStream
    Move
    SaveToFile
    SaveToStream
    SetTextDerived from TPersistentGetNamePathDerived from TObjectAfterConstruction
    BeforeDestruction
    ClassInfo
    ClassName
    ClassNameIs
    ClassParent
    ClassType
    CleanupInstance
    Create
    DefaultHandler
    Dispatch
    FieldAddress
    Free
    FreeInstance
    GetInterface
    GetInterfaceEntry
    GetInterfaceTableInheritsFrom
    InitInstance
    InstanceSize
    MethodAddress
    MethodName
    NewInstance
    SafeCallException
    如果要全部详细写的话,估计我这个贴子连发三次也发不完
      

  2.   

    说说几个关键的地方
    Tstrings := Tstringlist.creat;
    赋值:
    t2.Assign(t1);
      

  3.   

    TStrings is the base class for objects that represent a list of strings.UnitClassesDescriptionDerive a class from TStrings to store and manipulate a list of strings. TStrings contains abstract methods and should not be directly instantiated.Descendants of TStrings can represent several individual strings, such as the individual lines that appear in a list box. Some objects use descendants of TStrings to represent one long body of text so that it can be manipulated in smaller chunks.TStrings introduces many properties and methods toAdd or delete strings at specified positions in the list.
    Rearrange the strings in the list.
    Access the string at a particular location.
    Read the strings from or write the strings to a file or stream.
    Associate an object with each string in the list.
      

  4.   

    自己查帮助吧:选中Tstrings按F1,关于她的说明、属性、方法什么都有了,还有实例
      

  5.   

    呵呵,来晚了,大家把help都贴出来了。
    给你个建议吧,多用delphi的F1。受益匪浅的。
      

  6.   

    查看Help不就可以得到吗,还要求人吗
      

  7.   

    Tstrings类简单介绍及实例
                      高红岩(ghyghost)在DELPHI的程序开发过程中Tstrings类的使用是比较频繁的,下面就此类在DELPHI5的开发环境中进行一下简单的介绍及实例(注:本文只对tstrings类中的方法及属性进行介绍,从其父类继承的属性及方法不属本文讨论之内)。 
    Add
    原型:function Add(const S: string): Integer; virtual;
    注解:此方法是在字符表中的后面添加字符串,返回值是新添加字符串的索引值。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    for i:=1 to 10 do
    listbox1.Items.Add(inttostr(i));
    end;
    AddStrings
    原型:procedure AddStrings(Strings: TStrings); virtual;
    注解:从字符表中添加一组字符表。
    实例:
    procedure TForm1.Button2Click(Sender: TObject);
    var
    abc:tstringlist;
    begin
    abc:=tstringlist.Create;
    abc.Assign(listbox1.Items);
    listbox2.Items.AddStrings(abc);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
    i:integer;
    begin
    for i:=1 to 10 do
    listbox1.Items.Add(inttostr(i));
    end;Append
    原型:procedure Append(const S: string);
    注解:此方法是在字符表中的后面添加字符串。 
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Items.Append(’you will win!!’);
    end;Assign
    原型:procedure Assign(Source: TPersistent); override;
    注解:用此方法从另一个兼容的对象中的值赋给此对象,相当于复制和赋值的功能。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    for i:=1 to 10 do
    begin
    listbox1.items.add(inttostr(i));
    end;
    listbox2.items.Assign(listbox1.items);
    end;BeginUpdate
    原型:procedure BeginUpdate;
    注解:此方法是在字符串列表与可视化列表控件进行操作时使用的,目的是防止添加或删除item时进行刷新(在大数据量进行添加或删除操作时是很费时间的)。与EndUpdate进行配对操作。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    listbox1.Items.BeginUpdate;
    for i:=0 to 10000 do
    begin
    listbox1.items.Add(inttostr(i));
    end;
    listbox1.Items.EndUpdate;
    end;Clear
    原型:procedure Clear; virtual; abstract;
    注解:此方法清除字符表中全部的内容
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    i:integer;
    begin
    for i:=0 to 10 do
    listbox1.items.add(inttostr(i));
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Items.Clear;
    end;Delete
    原型:procedure Delete(Index: Integer); virtual; abstract;
    注解:此方法通过索引值删除指定的字符串。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    i:integer;
    begin
    for i:=0 to 10 do
    listbox1.items.add(inttostr(i));
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Items.Delete(listbox1.ItemIndex);
    end;Destroy
    原型:destructor Destroy; override;
    注解:消毁一个TStrings类的实例。
    实例:
    var
    Form1: TForm1;
    aaa:boolean;
    bbb:tstringlist;
    implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
    aaa:=true;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    if aaa=true then
    begin
    bbb:=tstringlist.create;
    aaa:=false;
    end
    else
    begin
    bbb.Destroy;
    aaa:=true;
    end;
    end;end.
    EndUpdate
    原型:procedure EndUpdate;
    注解:此方法是在字符串列表与可视化列表控件进行操作时使用的,目的是防止添加或删除item时进行刷新(在大数据量进行添加或删除操作时是很费时间的)。与BeginUpdate进行配对操作。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    listbox1.Items.BeginUpdate;
    for i:=0 to 10000 do
    begin
    listbox1.items.Add(inttostr(i));
    end;
    listbox1.Items.EndUpdate;
    end;Equals
    原型:function Equals(Strings: TStrings): Boolean;
    注解:此方法为判断两个Tstrings类中的内容是否相当,如果相等返回为true,不等返回为false。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    i:integer;
    begin
    for i:=0 to 10 do
    begin
    listbox1.items.add(inttostr(i));
    listbox2.items.add(inttostr(i));
    end;for i:=0 to 9 do
    begin
    listbox3.items.add(inttostr(i));
    end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    if listbox1.items.Equals(listbox2.items) then
    showmessage(’相等’)
    else
    showmessage(’不相等’);end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    if listbox2.items.Equals(listbox3.items) then
    showmessage(’相等’)
    else
    showmessage(’不相等’);
    end;Exchange
    原型:procedure Exchange(Index1, Index2: Integer); virtual;
    注解:此方法是借助两个字符串在表中的索引而调换位置。与move区别是(If either string has an associated object, Exchange changes the position of the object as well.如果这个字符串有一个链接的对象,那么这个对象的位置也随着字符串的位置改变而改变。)
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:integer;
    begin
    for i:=0 to 10 do
    listbox1.items.add(inttostr(i));listbox1.items.Exchange(0,10);
    end;GetText
    原型:function GetText: PChar; virtual;
    注解:取得所有此类中的字符。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    listbox1.Items.add(’1’);
    listbox1.Items.add(’1’);
    listbox1.Items.add(’1’);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(string(listbox1.Items.GetText));
    end;IndexOf
    原型:function IndexOf(const S: string): Integer; virtual;
    注解:通过字符串常量来得到在此类中的索引值。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    listbox1.Items.add(’1’);
    listbox1.Items.add(’2’);
    listbox1.Items.add(’3’);
    listbox1.Items.add(’4’);
    listbox1.Items.add(’5’);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(inttostr(listbox1.Items.indexof(’5’)));
    end;Insert
    原型:procedure Insert(Index: Integer; const S: string); virtual; abstract;
    注解:在指定的索引位置插入一个字符串。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    listbox1.Items.add(’1’);
    listbox1.Items.add(’2’);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Items.Insert(0,’abc’);
    end;LoadFromFile
    原型:procedure LoadFromFile(const FileName: string); virtual;
    注解:从指定的文件名装载文件内容。
    实例:
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    listbox1.items.LoadFromFile(’c:\abc.txt’);
    end;LoadFromStream
    原型:procedure LoadFromStream(Stream: TStream); virtual;
    注解:从流中装载文件。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    abc:tmemorystream;
    begin
    abc:=tmemorystream.create;
    abc.LoadFromFile(’c:\csdn.txt’);
    memo1.lines.LoadFromStream(abc);
    end;
    Move
    原型:procedure Move(CurIndex, NewIndex: Integer); virtual;
    注解:交换两个以索引为参数的字符串。与Exchange不同的是(If the string has an associated object, the object remains associated with the string in its new position.如果这个字符串有一个对象,那么这个对象的位置不变,自动链接到新的字符串)
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ListBox1.Items.Move(ListBox1.ItemIndex, 0);
    end;SaveToFile
    原型:procedure SaveToFile(const FileName: string); virtual;
    注解:通过参数来把tstrings中的内容存成文件。
    实例:
    procedure TForm1.Button2Click(Sender: TObject);
    begin
    memo1.Lines.SaveToFile(’c:\abc.txt’);
    end;SaveToStream
    原型:procedure SaveToStream(Stream: TStream); virtual;
    注解:保存成流。
    实例:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    abc:tstringlist;
    abcd:tmemorystream;
    begin
    abc:=tstringlist.create;
    abcd:=tmemorystream.create;
    abc.add(’1’);
    abc.add(’1’);
    abc.add(’1’);
    abc.add(’1’);
    abc.SaveToStream(abcd);
    abcd.Position:=0;
    memo1.lines.loadfromstream(abcd);
    end;
    SetText
    原型:procedure SetText(Text: PChar); virtual;
    注解:设置tstrings类中的内容。
    实例:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    i:integer;
    begin
    for i:=0 to 10 do
    begin
    listbox1.items.add(inttostr(i));
    end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    listbox1.Items.SetText(pchar(’aa’));
    end;