Bonjour
Avez vous un bout de code ou composant gratuit pour la génération de
l'Auto completion dans une combobox
exemple dans une combobox j'ai
aa1
aa2
aa3
bb1
bb2
bb3
cc1
cc2
cc3
exemple quand je saisie sur la combobox cc1 il ne reste
plus que la liste avec cc1,cc2,cc3
voici un bout de code en dessous
mais quand je tape cc il y a encore dans la listbox
de aa1 à cc3
ou alors des combobox qui filtre ?
bien entendu je ne veux pas passer par une table
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ComboBox1: TComboBox; procedure ComboBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ComboBox1Change(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; LastKey: Word; implementation {$R *.DFM} procedure TForm1.ComboBox1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin LastKey := Key; end; procedure TForm1.ComboBox1Change(Sender: TObject); var Srch: string; ix: Integer; begin Srch := combobox1.Text; if LastKey = $08 then begin LastKey := 0; Exit; end; LastKey := 0; ix := combobox1.Perform(CB_FINDSTRING, - 1, Longint(PChar(Srch))); // ici on recharge la listbox if ix > CB_ERR then begin combobox1.ItemIndex := ix; combobox1.SelStart := Length(Srch); combobox1.SelLength := (Length(combobox1.Text) - Length(Srch)); end; end; end.
Partager