给我提个建议,我想实现像delphi帮助里的 索引 那样的效果即在一个listbox 或combobox的下拉框里有很多项,在一个文本框里输入数据
随着输入内容的改变,下拉框里的也随着改变

解决方案 »

  1.   

    onchange事件里加处理,好像很麻烦
      

  2.   

    你可以建了临时表,把listbox1的里面的文本列表存入,然后利用SQL的‘select 列值 from tmptable where 列名 like %value%’找出符合条件的记录再重新插入到listbox的Items中去就OK
      

  3.   

    首先ListBox1是经过排序的。对于ListBox1可以用Sorted来排序。然后在edit的onchange事件中加入下面的
    procedure TForm1.Edit1Change(Sender: TObject);
    var
      I : Integer ;
    begin
      for I := 0 to ListBox1.Count - 1 do
      begin
        if pos(edit1.Text ,ListBox1.Items[i]) =1 then
        begin
           ListBox1.ItemIndex := i ;
           break;
        end;
      end;
    end;
      

  4.   

    这个处理需要用到I_AutoComplete接口,我这有个例子,给你贴出来连同需要的单元,你看看,编译时运行或许会报错,但没关系,直接运行可执行程序没错。主窗体代码unit Main;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ShlIntf, ActiveX, ComObj, StdCtrls, StrTools;type
      TAutoCompleteForm = class(TForm)
        CompletionEdit: TEdit;
        CompletionLabel: TLabel;
        SourceGroupBox: TGroupBox;
        SourceMemo: TMemo;
        procedure FormCreate(Sender: TObject);
      private
        FAutoComplete: IAutoComplete2;
        FStrings: IUnknown;
      end;var
      AutoCompleteForm: TAutoCompleteForm;implementation{$R *.DFM}{ TAutoCompleteForm }procedure TAutoCompleteForm.FormCreate(Sender: TObject);
    begin
      FAutoComplete  := CreateComObject(CLSID_AutoComplete) as IAutoComplete2;
      FStrings := TEnumString.Create(SourceMemo.Lines) as IUnknown;
      OleCheck(FAutoComplete.SetOptions(ACO_AUTOSUGGEST or ACO_UPDOWNKEYDROPSLIST));
      OleCheck(FAutoComplete.Init(CompletionEdit.Handle, FStrings, nil, nil));
    end;end.
      

  5.   

    需要的两个单元(********************************************************)
    (*                                                      *)
    (*      Object Modeler Class Library                    *)
    (*                                                      *)
    (*      Open Source Released 2000                       *)
    (*                                                      *)
    (********************************************************)unit ShlIntf;interface{$I STD.INC}uses
      Windows;const
    // Class IDs
      {$EXTERNALSYM CLSID_AutoComplete}
      CLSID_AutoComplete: TGUID = (
        D1:$00BB2763; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));
      {$EXTERNALSYM CLSID_ACLHistory}
      CLSID_ACLHistory: TGUID = (
        D1:$00BB2764; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));
      {$EXTERNALSYM CLSID_ACListISF}
      CLSID_ACListISF: TGUID = (
        D1:$03C036F1; D2:$A186; D3:$11D0; D4:($82,$4A,$00,$AA,$00,$5B,$43,$83));
      {$EXTERNALSYM CLSID_ACLMRU}
      CLSID_ACLMRU: TGUID = (
        D1:$6756A641; D2:$DE71; D3:$11D0; D4:($83,$1B,$00,$AA,$00,$5B,$43,$83));
      {$EXTERNALSYM CLSID_ACLMulti}
      CLSID_ACLMulti: TGUID = (
        D1:$00BB2765; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));// Interface IDs
      {$EXTERNALSYM IID_IAutoComplete}
      IID_IAutoComplete: TGUID = (
        D1:$00BB2762; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));
      {$EXTERNALSYM IID_IAutoComplete2}
      IID_IAutoComplete2: TGUID = (
        D1:$EAC04BC0; D2:$3791; D3:$11D2; D4:($BB,$95,$00,$60,$97,$7B,$46,$4C));
      {$EXTERNALSYM IID_IAutoCompList}
      IID_IAutoCompList: TGUID = (
        D1:$00BB2760; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));
      {$EXTERNALSYM IID_IACList}
      IID_IACList: TGUID = (
        D1:$77A130B0; D2:$94FD; D3:$11D0; D4:($A5,$44,$00,$C0,$4F,$D7,$d0,$62));
      {$EXTERNALSYM IID_IACList2}
      IID_IACList2: TGUID = (
        D1:$470141A0; D2:$5186; D3:$11D2; D4:($BB,$B6,$00,$60,$97,$7B,$46,$4C));
      {$EXTERNALSYM IID_ICurrentWorkingDirectory}
      IID_ICurrentWorkingDirectory: TGUID = (
        D1:$91956D21; D2:$9276; D3:$11D1; D4:($92,$1A,$00,$60,$97,$DF,$5B,$D4));
      {$EXTERNALSYM IID_IObjMgr}
      IID_IObjMgr: TGUID = (
        D1:$00BB2761; D2:$6A77; D3:$11D0; D4:($A5,$35,$00,$C0,$4F,$D7,$D0,$62));// String constants for Interface IDs
      SID_IAutoComplete            = '{00BB2762-6A77-11D0-A535-00C04FD7D062}';
      SID_IAutoComplete2           = '{EAC04BC0-3791-11D2-BB95-0060977B464C}';
      SID_IACList                  = '{77A130B0-94FD-11D0-A544-00C04FD7d062}';
      SID_IACList2                 = '{470141A0-5186-11D2-BBB6-0060977B464C}';
      SID_ICurrentWorkingDirectory = '{91956D21-9276-11D1-921A-006097DF5BD4}';
      SID_IObjMgr                  = '{00BB2761-6A77-11D0-A535-00C04FD7D062}';type
      {$EXTERNALSYM IAutoComplete}
      IAutoComplete = interface(IUnknown)
        [SID_IAutoComplete]
        function Init(hwndEdit: HWND; punkACL: IUnknown; pwszRegKeyPath: PWideChar;
          pwszQuickComplete: PWideChar): HResult; stdcall;
        function Enable(fEnable: Boolean): HResult; stdcall;
       end;const
      {$EXTERNALSYM ACO_NONE}
      ACO_NONE               = $0000;
      {$EXTERNALSYM ACO_AUTOSUGGEST}
      ACO_AUTOSUGGEST        = $0001;
      {$EXTERNALSYM ACO_AUTOAPPEND}
      ACO_AUTOAPPEND         = $0002;
      {$EXTERNALSYM ACO_SEARCH}
      ACO_SEARCH             = $0004;
      {$EXTERNALSYM ACO_FILTERPREFIXES}
      ACO_FILTERPREFIXES     = $0008;
      {$EXTERNALSYM ACO_USETAB}
      ACO_USETAB             = $0010;
      {$EXTERNALSYM ACO_UPDOWNKEYDROPSLIST}
      ACO_UPDOWNKEYDROPSLIST = $0020;
      {$EXTERNALSYM ACO_RTLREADING}
      ACO_RTLREADING         = $0040;type
      {$EXTERNALSYM IAutoComplete2}
      IAutoComplete2 = interface(IAutoComplete)
        [SID_IAutoComplete2]
        function SetOptions(dwFlag: DWORD): HResult; stdcall;
        function GetOptions(out dwFlag: DWORD): HResult; stdcall;
      end;  {$EXTERNALSYM IACList}
      IACList = interface(IUnknown)
        [SID_IACList]
        function Expand(pszExpand: PWideChar): HResult; stdcall;
      end;const
      ACLO_NONE            = 0;    // don't enumerate anything
      ACLO_CURRENTDIR      = 1;    // enumerate current directory
      ACLO_MYCOMPUTER      = 2;    // enumerate MyComputer
      ACLO_DESKTOP         = 4;    // enumerate Desktop Folder
      ACLO_FAVORITES       = 8;    // enumerate Favorites Folder
      ACLO_FILESYSONLY     = 16;   // enumerate only the file systemtype
      {$EXTERNALSYM IACList2}
      IACList2 = interface(IACList)
        [SID_IACList2]
        function SetOptions(dwFlag: DWORD): HResult; stdcall;
        function GetOptions(out pdwFlag: DWORD): HResult; stdcall;
      end;  {$EXTERNALSYM IID_ICurrentWorkingDirectory}
      ICurrentWorkingDirectory = interface(IUnknown)
        [SID_ICurrentWorkingDirectory]
        function GetDirectory(pwzPath: PWideChar; cchSize: DWORD): HResult; stdcall;
        function SetDirectory(pwzPath: PWideChar): HResult; stdcall;
      end;  {$EXTERNALSYM IObjMgr}
      IObjMgr = interface(IUnknown)
        [SID_IObjMgr]
        function Append(punk: IUnknown): HResult; stdcall;
        function Remove(punk: IUnknown): HResult; stdcall;
      end;implementationend.
      

  6.   


    (********************************************************)
    (*                                                      *)
    (*      Object Modeler Class Library                    *)
    (*                                                      *)
    (*      Open Source Released 2000                       *)
    (*                                                      *)
    (********************************************************)unit StrTools;interface{$I STD.INC}uses
      Windows, SysUtils, Classes, Math, TypInfo, ActiveX;const
       Alpha = ['A'..'Z', 'a'..'z'];
       Numeric = ['0'..'9'];
       AlphaNumeric = Alpha + Numeric;{ The AdvanceToken function does a case insensitive search of Buffer for
      SearchStr, and returns True if a match is found. Buffer is modified to
      point to the character after the match. }function AdvanceToken(var Buffer: PChar; const SearchStr: string): Boolean;{ The GetComponentName function returns the name of the Component parameter. If
      the component has no name, the function creates a unique name. }function GetComponentName(Component: TComponent): string;{ The GetComponentPath function returns a string that represents the ownership
      of the Component parameter. }function GetComponentPath(Component: TComponent): string;{ The MaskConvert function returns a formated string from Source as defined by
      Mask. Any characters in Source that don't match the Mask string are replaced
      with DefaultChar.  Mask can contain the following special characters:    'C' Filters source string for the first occurance of an Alpha character
        'D' Filters source string for the first occurance of an Numeric character
        '?' Accepts any character   For example:
         MaskConvert('1235551212', '(DDD) DDD-DDDDD', '0') returns '(123) 555-1212'
         MaskConvert('(123) 555-1212', 'DDDDDDDDDDD', '0') returns '1235551212' }function MaskConvert(const Source: string; const Mask: string; DefaultChar: Char): string;{ The SearchAndReplace procedure performs a case-sensitive search for SearchStr
      and calls ReplaceFunc for each a match found. If ReplaceFunc returns True then
      SearchStr is replaced with S. }type
      TReplaceFunc = function (var S: string): Boolean;procedure SearchAndReplace(Strings: TStrings; const SearchStr: string; ReplaceFunc: TReplaceFunc);{ The StrPad procedure copies Source string into the Dest buffer, aligning it
      left or right and filling any extra bytes with the Pad character. }type
      TPadAlign = (paLeft, paRight);procedure StrPad(const Source: string; Dest: PChar; Size: Integer;
      PadAlign: TPadAlign; Pad: Char);{ The TrimSeparator function returns a copy of S from the character after the
      Separator parameter to the end of the string. }function TrimSeparator(const S: string; Separator: Char): string;{ TComplexField class }type
      EComplexFieldError = class(Exception);  TComplexField = class
      private
        FData: string;
        function GetCount: Integer;
        function GetItem(Index: Integer): string;
        procedure SetItem(Index: Integer; const Value: string);
      public
        function IndexOf(const S: string): Integer;
        property Count: Integer read GetCount;
        property Data: string read FData write FData;
        property Item[index: Integer]: string read GetItem write SetItem; default;
      end;{ TEnumString class }  TEnumString = class(TInterfacedObject, IEnumString)
      private
        FStrings: TStrings;
        FIndex: Integer;
      protected
        { IEnumString }
        function Next(celt: Longint; out elt;
          pceltFetched: PLongint): HResult; stdcall;
        function Skip(celt: Longint): HResult; stdcall;
        function Reset: HResult; stdcall;
        function Clone(out enm: IEnumString): HResult; stdcall;
      public
        constructor Create(Strings: TStrings);
      end;implementationuses
      StrConst;function AdvanceToken(var Buffer: PChar; const SearchStr: string): Boolean;
    var
      Token: PChar;
    begin
      Token := PChar(SearchStr);
      while Buffer^ <> #0 do
      begin
        if UpCase(Buffer^) = Token^ then
          Inc(Token)
        else if Token <> PChar(SearchStr) then
        begin
          Token := PChar(SearchStr);
          if UpCase(Buffer^) = Token^ then
            Inc(Token);
        end;
        Inc(Buffer);
        if Token^ = #0 then
          Break;
      end;
      Result := Token^ = #0;
    end;function GetComponentName(Component: TComponent): string;
    var
      S: string;
      I: Integer;
    begin
      Result := Component.Name;
      if Result = '' then
      begin
        S := Component.ClassName;
        I := 1;
        if Component.Owner <> nil then
          while Component.Owner.FindComponent(PChar(@S[2]) + IntToStr(I)) <> nil do
            Inc(I);
        Result := PChar(@S[2]) + IntToStr(I);
      end;
    end;function GetComponentPath(Component: TComponent): string;
    var
      S: string;
    begin
      if Component <> nil then
      begin
        S := GetComponentPath(Component.Owner);
        if S <> '' then
          Result := S + DotSep + GetComponentName(Component)
        else
          Result := S + GetComponentName(Component);
      end
      else
        Result := '';
    end;function MaskConvert(const Source: string; const Mask: string; DefaultChar: Char): string;
    var
      P: PChar;
      I: Integer;  procedure DefaultAction;
      begin
        if UpCase(Mask[I]) in ['C', 'D', '?'] then
          Result := Result + DefaultChar
        else
          Result := Result + Mask[I];
      end;begin
      P := PChar(Source);
      Result := '';
      for I := 1 to Length(Mask) do
      if P^ <> #0 then
      begin
        case UpCase(Mask[I]) of
          'C':
          begin
            while (P^ <> #0) and (not (P^ in Alpha)) do
              Inc(P);
            if P^ <> #0 then
              Result := Result + P^
            else
            begin
              DefaultAction;
              Continue;
            end;
          end;
          'D':
          begin
            while (P^ <> #0) and (not (P^ in Numeric)) do
              Inc(P);
            if P^ <> #0 then
              Result := Result + P^
            else
            begin
              DefaultAction;
              Continue;
            end;
          end;
          '?':
            Result := Result + P^
          else
          begin
            Result := Result + Mask[I];
            Continue;
          end;
        end;
        Inc(P);
      end
      else
        DefaultAction;
    end;procedure SearchAndReplace(Strings: TStrings; const SearchStr: string; ReplaceFunc: TReplaceFunc);
    var
      ReplaceStr: string;
      Buffer: string;
      Match: Integer;
      I: Integer;
    begin
      ReplaceStr := '';
      Strings.BeginUpdate;
      try
        for I := 0 to Strings.Count - 1 do
        begin
          Buffer := Strings[I];
          Match := Pos(SearchStr, Buffer);
          while (Match > 0) and ReplaceFunc(ReplaceStr) do
          begin
            Buffer := Copy(Buffer, 1, Match-1) + ReplaceStr + Copy(Buffer, Match + Length(SearchStr), Length(Buffer));
            Match := Pos(SearchStr, Buffer);
          end;
          Strings[I] := Buffer;
        end;
      finally
        Strings.EndUpdate;
      end;
    end;procedure StrPad(const Source: string; Dest: PChar; Size: Integer; PadAlign: TPadAlign; Pad: Char);
    begin
      FillMemory(Dest, Size, Byte(Pad));
      if PadAlign = paRight then
        Inc(Dest, Size - MinIntValue([Length(Source), Size]));
      CopyMemory(Dest, Pointer(Source), MinIntValue([Length(Source), Size]));
    end;function TrimSeparator(const S: string; Separator: Char): string;
    var
      P: PChar;
    begin
      Result := '';
      if S <> '' then
      begin
        P := PChar(S);
        while (P^ <> #0) and (P^ <> Separator) do
          Inc(P);
        if P^ <> #0 then
          Inc(P);
        Result := P;
      end;
    end;{ TComplexField }const
      ComplexCharacters = AlphaNumeric;
      ComplexSeperators = [#1..#255] - ComplexCharacters;
      

  7.   


    function TComplexField.GetCount: Integer;
    var
      P: PChar;
    begin
      Result := 0;
      if FData <> '' then
      begin
        P := PChar(FData);
        while P^ <> #0 do
        begin
          while P^ in ComplexSeperators do
            Inc(P);
          if P^ in ComplexCharacters then
            Inc(Result);
          while P^ in ComplexCharacters do
            Inc(P);
        end;
      end;
    end;function TComplexField.IndexOf(const S: string): Integer;
    var
      TempStr: string;
      I: Integer;
    begin
      Result := -1;
      TempStr := UpperCase(S);
      for I := 0 to Count - 1 do
        if TempStr = UpperCase(Item[I]) then
        begin
          Result := I;
          Break;
        end;
    end;function TComplexField.GetItem(Index: Integer): string;
    var
      StartPos: PChar;
      P: PChar;
      I: Integer;
    begin
      Result := '';
      if (Index < 0) or (Index > Count - 1) then
        raise EComplexFieldError.Create(SRangeIndexError);
      P := PChar(FData);
      I := 0;
      while P^ <> #0 do
      begin
        while P^ in ComplexSeperators do
          Inc(P);
        StartPos := P;
        if P^ in ComplexCharacters then
        begin
          while P^ in ComplexCharacters do
            Inc(P);
          if I = Index then
          begin
            SetString(Result, StartPos, P - StartPos);
            Break;
          end;
          Inc(I);
        end;
      end;
    end;procedure TComplexField.SetItem(Index: Integer; const Value: string);
    var
      P: PChar;
      StartPos: PChar;
      I: Integer;
    begin
      if (Index < 0) or (Index > Count - 1) then
        raise EComplexFieldError.Create(SRangeIndexError);
      P := PChar(FData);
      StartPos := P;
      I := -1;
      while P^ <> #0 do
      begin
        while P^ in ComplexSeperators do
          Inc(P);
        StartPos := P;
        while P^ in ComplexCharacters do
          Inc(P);
        Inc(I);
        if I = Index then
          Break;
      end;
      FData := Copy(FData, 1, StartPos - PChar(FData)) + Value  +
        Copy(FData, P - PChar(FData) + 1, Length(FData));
    end;{ TEnumString }constructor TEnumString.Create(Strings: TStrings);
    begin
      inherited Create;
      FStrings := Strings;
    end;{ TEnumString.IEnumString }function TEnumString.Next(celt: Longint;
      out elt; pceltFetched: PLongint): HResult;
    var
      I: Integer;
    begin
      I := 0;
      while (I < celt) and (FIndex < FStrings.Count) do
      begin
        TPointerList(elt)[I] := PWideChar(WideString(FStrings[FIndex]));
        Inc(I);
        Inc(FIndex);
      end;
      if pceltFetched <> nil then pceltFetched^ := I;
      if I = celt then Result := S_OK else Result := S_FALSE;
    end;
    function TEnumString.Skip(celt: Longint): HResult;
    begin
      if (FIndex + celt) <= FStrings.Count then
      begin
        Inc(FIndex, celt);
        Result := S_OK;
      end
      else
      begin
        FIndex := FStrings.Count;
        Result := S_FALSE;
      end;
    end;function TEnumString.Reset: HResult;
    begin
      FIndex := 0;
      Result := S_OK;
    end;function TEnumString.Clone(out enm: IEnumString): HResult;
    begin
      try
        enm := TEnumString.Create(FStrings);
        Result := S_OK;
      except
        Result := E_UNEXPECTED;
      end;
    end;end.
      

  8.   

    你粘贴下去,试试看,在SourceMemo中写入一些字符串
      

  9.   

    plfire(pl)的方法 我试过 可以还有其他方法 不用数据库可以吗
      

  10.   

    procedure TForm1.Edit1Change(Sender: TObject);
    var
      I : Integer ;
    begin
      if edit1.Text='' then begin
        ListBox1.ItemIndex := -1 ;
        exit ;
      end;
      for I := 0 to ListBox1.Count - 1 do
      begin
        if pos(edit1.Text ,ListBox1.Items[i]) =1 then
        begin
           ListBox1.ItemIndex := i ;
           break;
        end;
      end;end;
      

  11.   

    不麻烦,同意
     plfire(pl) ( ) 信誉:100  2003-04-25 15:37:00  得分:0 
     
     
      你可以建了临时表,把listbox1的里面的文本列表存入,然后利用SQL的‘select 列值 from tmptable where 列名 like %value%’找出符合条件的记录再重新插入到listbox的Items中去就OK
      
     
      

  12.   

    不同意 plfire(pl) ( ) 信誉:100  2003-04-25 15:37:00  得分:0 如果数据量大的时候,你要想让客户等你多久?不怕慢吗?可以用1000条数据来试验一下
      

  13.   

    代码真的多多,,我刚才写的代码,,
    运行通过
    能满足楼主的需要,,
    procedure TForm1.Edit1Change(Sender: TObject);
    var
    a:pchar;
    begin
    a:=pchar(edit1.text);
    listbox1.ItemIndex:=sendmessage(listbox1.handle,LB_FINDSTRING,-1,integer(a));
    showmessage(inttostr(sendmessage(listbox1.handle,LB_FINDSTRING,-1,integer(a))));
    end;
      

  14.   

    ghyghost(著名关心CSDN结贴率爱国主义人士代表) 的不行,
    你输入第一个可能判断到了,怎么根据第二个和以后的输入定位到字符串呢??
    我的绝对可以
      

  15.   

    u2m(UpToMe) 兄,,
    不会的,,
    我在机器上试验了,可以实现字符串查找,,你再试一下,,
      

  16.   

    我现在有些不明白楼主的意思,
    如果要实现MSDN方式的索引自动查找,,
    我的代码绝对是可以的,
    才上机试验过,listBOX里有98
    97
    96
    在edit1.text中输入9定位,,,,,
    然后继续再输入6,,
    自动定位到96这个INDEX中,,
      

  17.   

    我认为,这个如果数据量不大的话(几十条或一两百条),建立两个ListBox,一个存放数据(不显示),另一个可以显示内容,然后逐条搜索就行了,程序很简单
    但是数据量的话建议使用数据库!否则……
      

  18.   

    function findindex(Astrlist:TStrings;srtSouce:String):Integer;//用2分法来查找最接近的字符所在位置
    var
     I : Integer ;
     Find : Boolean;
     A1,A2:Integer;
    begin
      Find := false;
      A1 := 0 ;
      A2 := Astrlist.Count - 1 ;
      repeat
        if  Astrlist[a1+((a2-a1) div 2)] < srtSouce then
        begin
            a1:= a1+(a2-a1) div 2 ;
        end else
        if Astrlist[a1+(a2-a1) div 2] = srtSouce then
        begin
           find := true;
           findindex := a1+(a2-a1) div 2;
        end else
        if Astrlist[a1+(a2-a1) div 2] > srtSouce then
        begin
            a2:= a1+(a2-a1) div 2 ;
        end ;
        if a2-a1 <=1 then
        begin
           findindex := a2;
           find := true ;
        end ;
      until find ;
    end;
    procedure TForm1.Edit1Change(Sender: TObject);
    begin
           ListBox1.ItemIndex := findindex(ListBox1.Items,edit1.Text)  ;
    end;
      

  19.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        ListBox1: TListBox;
        Edit1: TEdit;
        Button1: TButton;
        procedure Edit1Change(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Edit1Change(Sender: TObject);
    var
    a:pchar;
    begin
    a:=pchar(edit1.text);
    listbox1.ItemIndex:=sendmessage(listbox1.handle,LB_FINDSTRING,-1,integer(a));end;procedure TForm1.Button1Click(Sender: TObject);
    var
    a,b:integer;
    begin
    form1.ListBox1.items.BeginUpdate;
    for a:=1 to 300 do
      begin
       for b:=1 to 300 do
       begin
       listbox1.items.add(inttostr(a)+inttostr(b));
       end;
      end;
    form1.ListBox1.items.EndUpdate;
    end;end.
    listbox里的items里的count是有限制的,,
    写了一段程序,,
    插入item,
    出现了错误,
    COUNT过大,
    而在大型的程序中,
    几十万
    百万的数据是常有的事,,
    如果数据量小,
    可以用这个代码,
    我试了一下,
    在有30000左右行的item的情况下
    速度丝毫不差多少,望其它的朋友广提意见