Newsgroup: it.comp.lang.delphi
Titolo: Combo Box

come si fa ad avere una combobox che funziona cosě:
mentre digito dentro qualcosa mi completa quello che sto scrivendo
prelevando i valori dalla lista delle stringhe.
ovvero se ho le seguenti parole cane cannone cantico cena
se digito ce-> vedo scritto cena, se scrivo can-> mi viene fuori cane,
digitando cant->cantico etc
ho dato uno sguardo al componente combobox č non ho trovato come fare ciň.
Grazie
Ettore

 prelevando i valori dalla lista delle stringhe.
Ciao, ecco il sorgente di un componente che fa quello che cerchi  (fonte :
DSP o Torry)
(spero che nessuno me ne voglia... visto che 1. questo ng non ha un
repository
e 2. tanti messaggi spam e ot sono piů lunghi di questo :) ).
******************************************************
unit ComboBox;
interface
uses
{$ifdef Win32}
  Windows,
{$else}
  WinTypes, WinProcs,
{$endif}
  Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;
type
  TOnComplete = procedure (Sender: TObject; Key:Word; var
CompleteWith:String; var DoComplete:Boolean) of object;
  TIEComboBox = class(TComboBox)
  private
    FComplete:Boolean;
    FKey:Word;
    FMinLength:Word;
    FOnComplete:TOnComplete;
    procedure SetComplete(value:Boolean);
    procedure SetMinLength(value:Word);
  public
    OldHintHidePause:Integer;
    constructor Create(aOwner : TComponent); override;
  protected
    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
    procedure Change; override;
  published
    property Complete : Boolean read FComplete write SetComplete;
    property MinLengthComplete : Word read FMinLength write SetMinLength;
    property OnComplete : TOnComplete read FOnComplete write FOnComplete;
  end;
procedure Register;
implementation
procedure Register;
begin RegisterComponents('Extra', [TIEComboBox]) end;
{ TIEComboBox }
constructor TIEComboBox.create(aOwner : Tcomponent);
begin
  inherited create(aOwner);
  FComplete:=True;
  FKey:=0;
  FMinLength:=0;
end;
procedure TIEComboBox.KeyDown(var Key: Word; Shift: TShiftState);
begin
  Inherited KeyDown(Key,Shift);
  FKey:=Key;
  if key = vk_return then begin
   {$ifdef Win32}
      SendMessage(Handle, CB_SETEDITSEL, 0, makelparam(0,0));
   {$else}
      selstart:=0;
      sellength:=0;
   {$endif}
  end;
end;
procedure TIEComboBox.Change;
  var tmp:string;
      c,d:word;
      DoIt:boolean;
begin
   inherited Change;
   if (FComplete) and ((Style=csDropDown) or (Style=csSimple)) then
   if (FKey<>8) and (FKey<>46) and (length(text)>=FMinLength) and
(Items.Count>0) then
    begin
      tmp:=uppercase(text);
      for c:=0 to items.count-1 do
      begin
        if tmp=uppercase(copy(items.strings[c],1,length(tmp))) then
        begin
          d:=length(tmp);
tmp:=copy(items.strings[c],length(tmp)+1,length(items.strings[c])-length(tmp
));
          DoIt:=true;
          if assigned(FOnComplete) then FOnComplete(Self,FKey,tmp,DoIt);
          if Doit then
          begin
            text:=text+tmp;
 {$ifdef Win32}
            SendMessage(Handle, CB_SETEDITSEL, 0,
makelparam(d,length(text)));
 {$else}
            selstart:=d;
            sellength:=length(text)-d;
 {$endif}
          end;
          break;
        end;
      end;
    end;
end;
procedure TIEComboBox.SetComplete(value:Boolean);
begin FComplete:=value end;
procedure TIEComboBox.SetMinLength(value:Word);
begin FMinLength:=value end;
END.
*******************************************************************
Ciao, Davide DG

 ******************************************************
Ciao Molte Grazie Davide DG
Ettore