Bonjour,
Je veux savoir comment faire une recherche sur la liste "afficher" sur un DBLookupComboBox.
Exemple :
Si je tape e, il me sort juste la liste qui commence par e.
J'utilise Windows 10 et Delphi Tokyo.
Merci d'avance !
Bonjour,
Je veux savoir comment faire une recherche sur la liste "afficher" sur un DBLookupComboBox.
Exemple :
Si je tape e, il me sort juste la liste qui commence par e.
J'utilise Windows 10 et Delphi Tokyo.
Merci d'avance !
En même temps, c'est bon, tu tapes e, il te positionne sur le premier mot en e.
Je l'utilise rarement car je lui préfère un TDBComboBox rempli manuellement mais c'est le principe de l'autocomplétion, tu donnes le début, il te fournit une fin possible.
Ce qui me choque, c'est que tes libellés ne soient pas triés !
Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !![]()
Attention Troll Méchant !
"Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
L'ignorance n'excuse pas la médiocrité !
L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
Il faut avoir le courage de se tromper et d'apprendre de ses erreurs
Bonjour,
J'ai déjà utiliser un TDBComboBox, mais il affiche juste un enregistrement.
Est-ce que vous pouvez svp expliquer comment le remplir et comment faire le filtre ?
Cordialement.
TDBComboBox affiche en texte l'enregistrement en cours dans DataSet lié au DataSource.
Cela se remplit via Items qui est un TStrings, qui permet de gérer un Objects[] pour chaque item.
En général, j'utilise un TComboBox non connecté bien plus souple et pratique, car je ne fais que de l'objet faisant l'encapsulation de la couche Business.
J'ai ainsi des codes standardisés et partagés avec des composants GUI (TxxxGUIMagasin) qui utilisent une couche Entity (TxxxEntityMagasin) (cette dernière génère le SQL et encapsule le DataSet).
Partout où j'ai besoin d'un Combo sur une liste d'entité, j'ai l'assistant GUI commun que je réutilise. Dans certaines applications, il y a même un cache des thésaurus pour éviter des chargements répétés.
Chaque Items[] a un Object[] de type TMagasinComboObject.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 //------------------------------------------------------------------------------ procedure TModuleReverseDecisionTriMagasinForm.InitModeForceMagasinCombo(); begin // Dans Réception Transfert, il n'y avait pas de filtre particulier pour la liste des magasins mais on va tout de même exclure les Centrales ! TxxxGUIMagasin.LoadIntoStrings(TModuleReverse.Instance.DBConnection, cbxModeForceMagasin.Items, TModuleReverseReceptionObjetVersMagasin.MAGASIN_FAMILLE_CENTRALES); TxxxGUIMagasin.AddIntoStrings(TModuleReverse.Instance.DBConnection, cbxModeForceMagasin.Items, FBusiness.MagasinReception); cbxModeForceMagasin.ItemIndex := -1; end;L'objet GUI pour chaque Objects[]
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 //------------------------------------------------------------------------------ class procedure TxxxGUIMagasin.LoadIntoStrings(ADBConnection: TxxxDBConnection; AStrings: TStrings); var Magasins: TxxxEntityMagasin; begin if AStrings.Count <= 0 then begin Magasins := TxxxEntityMagasin.CreateAsSet(); try Magasins.Connection := ADBConnection; if Magasins.Load(TxxxBusinessMagasin.MakeOrderByMagasin()) then begin while not Magasins.EOF do begin AStrings.AddObject(Magasins.MagasinNom, TMagasinComboObject.Create(Magasins.MagasinCode, Magasins.MagasinNom)); Magasins.Next(); end; end; finally Magasins.Free(); end; end; end; //------------------------------------------------------------------------------ class procedure TxxxGUIMagasin.LoadIntoStrings(ADBConnection: TxxxDBConnection; AStrings: TStrings; AExcludedFamilleMagasin: TSysCharSet); var Magasins: TxxxEntityMagasin; begin if AStrings.Count <= 0 then begin Magasins := TxxxEntityMagasinFamille.CreateAsSet(); try Magasins.Connection := ADBConnection; if Magasins.Load(TxxxBusinessMagasin.MakeOrderByMagasin()) then begin while not Magasins.EOF do begin if not CharInSet(TxxxEntityMagasinFamille(Magasins).FamilleMagasinType, AExcludedFamilleMagasin) then AStrings.AddObject(Magasins.MagasinNom, TMagasinComboObject.Create(Magasins.MagasinCode, Magasins.MagasinNom)); Magasins.Next(); end; end; finally Magasins.Free(); end; end; end;
L'objet Entité
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 TMagasinComboObject = class strict private FMagasinCode: string; FMagasinLibelle: string; public constructor Create(AMagasin: TxxxEntityMagasin); overload; constructor Create(const AMagasinCode: string; const AMagasinLibelle: string); overload; property MagasinCode: string read FMagasinCode; property MagasinLibelle: string read FMagasinLibelle; class function GetSelectedMagasin(AComboBox: TComboBox): TMagasinComboObject; static; class function GetMagasinAt(AComboBox: TComboBox; AIndex: Integer): TMagasinComboObject; static; class function GetMagasinByCode(AComboBox: TComboBox; const AMagasinCode: string): TMagasinComboObject; static; class function IndexOfCode(AComboBox: TComboBox; const AMagasinCode: string): Integer; static; end;
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
61
62
63
64
65
66
67
68
69 /// <summary>Entité mappant la Table T_MAGASINxxx</summary> TxxxEntityMagasinCustom = class(TxxxDBEntity) public type TProperties = (pMagasinCode, pMagasinNom, pMagasinNomSociete, pEnseigneCode, pAdresseLigne1, pAdresseLigne2, pVille, pFamilleMagasinCode ... beaucoup trop de colonne); strict private const ORM_TABLE_NAME = 'T_MAGASINxxx'; ORM_FIELD_PROPERTY_ASSOCIATIONS: array[TProperties] of TxxxDBEntityFieldPropertyAssociation = ( (FieldName: 'Mxxx_CH_CODE'; PropertyName: 'MagasinCode' ), // PK (FieldName: 'Mxxx_CH_NOM'; PropertyName: 'MagasinNom' ), (FieldName: 'SA_CH_NOM'; PropertyName: 'MagasinNomSociete' ), (FieldName: 'EM_CH_ENSEIGNE'; PropertyName: 'EnseigneCode' ), // FK (FieldName: 'Mxxx_CH_ADRESSE1'; PropertyName: 'AdresseLigne1' ), (FieldName: 'Mxxx_CH_ADRESSE2'; PropertyName: 'AdresseLigne2' ), (FieldName: 'Mxxx_CH_VILLE'; PropertyName: 'Ville' ), (FieldName: 'FM_C_TYPEFAMILLEMAGASIN'; PropertyName: 'FamilleMagasinCode' ), // FK ... beaucoup trop de colonne ); ORM_FIELD_THESAURUS: array[0..5] of TxxxDBEntityFieldThesaurusAssociation = ( (FieldName: 'EM_CH_ENSEIGNE'; ThesaurusTableName: 'TP_ENSEIGNEMAGASIN'; ThesaurusLabelName: 'EM_CH_LIBELLE'; ThesaurusKeyName: 'EM_CH_ENSEIGNE'), (FieldName: 'FM_C_TYPEFAMILLEMAGASIN'; ThesaurusTableName: 'T_FAMILLEMAGASIN'; ThesaurusLabelName: 'FM_CH_DESCRIPTIF'; ThesaurusKeyName: 'FM_C_TYPEFAMILLEMAGASIN'), ... beaucoup trop de colonne ); public // Accès aux Meta-Données ORM Brutes type Schema = class private class function GetTableName(): string; static; class function GetFieldName(PropertyIndex: TProperties): string; static; class function GetFieldThesaurus(PropertyIndex: TProperties): TxxxDBEntityFieldThesaurusAssociation; static; public class property TableName: string read GetTableName; class property FieldNames[PropertyIndex: TProperties]: string read GetFieldName; class property FieldThesaurus[PropertyIndex: TProperties]: TxxxDBEntityFieldThesaurusAssociation read GetFieldThesaurus; end; strict protected class procedure RegisterORM(AClass: TClass); protected // Propriétés ORM non publiées property MagasinCode: string index TProperties.pMagasinCode read GetStringPropByIndex write SetStringPropByIndex; property MagasinNom: string index TProperties.pMagasinNom read GetStringPropByIndex write SetStringPropByIndex; property MagasinNomSociete: string index TProperties.pMagasinNomSociete read GetStringPropByIndex write SetStringPropByIndex; property EnseigneCode: string index TProperties.pEnseigneCode read GetStringPropByIndex write SetStringPropByIndex; property AdresseLigne1: IxxxDBEntityNullableString index TProperties.pAdresseLigne1 read GetNullableStringPropByIndex; property AdresseLigne2: IxxxDBEntityNullableString index TProperties.pAdresseLigne2 read GetNullableStringPropByIndex; property Ville: string index TProperties.pVille read GetStringPropByIndex write SetStringPropByIndex; property FamilleMagasinCode: string index TProperties.pFamilleMagasinCode read GetStringPropByIndex write SetStringPropByIndex; ... beaucoup trop de colonne end; /// <summary>Entité mappant la Table T_MAGASINxxx se limitant aux informations basiques : Code, Nom et Adresse</summary> TxxxEntityMagasin = class(TxxxEntityMagasinCustom) published // Propriétés property MagasinCode; property MagasinNom; property EnseigneCode; property AdresseLigne1; property AdresseLigne2; property Ville; public // Constructeurs de Classe class constructor Create(); end;
Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !![]()
Attention Troll Méchant !
"Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
L'ignorance n'excuse pas la médiocrité !
L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
Il faut avoir le courage de se tromper et d'apprendre de ses erreurs
Merci, je vais voir si j'arrive à l'intégrer.
Est-ce que tu peux créer svp un petit projet de démo avec ce code ?
Partager