Soyez le premier à donner votre avis sur cette source.
Vue 8 356 fois - Téléchargée 742 fois
unit ComboBoxRechInc; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TRmethode = (affNormal, affIncrement); TIncComboBox = class(TComboBox) private { Déclarations privées } FFonct: TRmethode; nMatchingLine: integer; Procedure Change; override; function FindMatchingLineWithText(s: string): integer; function GetSelectedText: string; protected { Déclarations protégées } public { Déclarations publiques } Constructor Create(Owner: TComponent); Override; published { Déclarations publiées } Property Affichage: TrMethode Read FFonct Write FFonct; end; procedure Register; implementation const NO_MATCHING_LINE = -1; Constructor TIncComboBox.Create(Owner: TComponent); begin Inherited create(Owner); FFonct := affIncrement; end; {Evènement: Modification dans l'edit du combo} procedure TIncComboBox.Change; var iSelStart:integer; begin If FFonct = affIncrement then begin nMatchingLine := NO_MATCHING_LINE; if self.text <> '' then begin if FindMatchingLineWithText(self.text) <> NO_MATCHING_LINE then begin {Si une chaîne matche on complète et on inverse la partie non saisie} if length(self.text) <> length(GetSelectedText) then begin iSelStart := length(self.text); self.text := GetSelectedText; self.selStart := iSelStart; self.selLength := length(self.text)-iSelStart; end; end; end; end; inherited Change; end; {Se positionner sur la bonne ligne en fonction du texte} function TIncComboBox.FindMatchingLineWithText(s: string): integer; begin nMatchingLine := NO_MATCHING_LINE; for Result := 0 to self.items.count - 1 do begin if upperCase(copy(self.items[Result],1,length(s))) <> upperCase(s) then continue; nMatchingLine := Result; break; end; Result := nMatchingLine; end; {Récupérer le texte de la ligne courante} function TIncComboBox.GetSelectedText: string; begin Result := self.items[nMatchingLine]; end; procedure Register; begin RegisterComponents('Fd Components', [TIncComboBox]); end; end.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.