jennybless
Messages postés38Date d'inscriptionsamedi 30 septembre 2006StatutMembreDernière intervention10 août 2007
-
11 juin 2007 à 20:26
cs_douly
Messages postés11Date d'inscriptiondimanche 17 juin 2007StatutMembreDernière intervention29 août 2007
-
17 juin 2007 à 01:18
Salut!
J'aimerai bien qu'à l'aide de ces codes que j'ai écrit qu'apparaisse un message disant qu'un
ou plusieurs tedits n'ont pas été remplis.
type
TForm1 = class(TForm)
private
{ Private declarations }
CheckForBlankText : Boolean ;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//commence ici
function CheckForBlankText : Boolean ;
var
n : LongInt ;
begin
Result := false ;
for n := 0 to ( ComponentCount - 1 ) do
begin
if ( components[n].ClassType = TEdit ) then
begin
if TEdit (components[n]).text = '' then
begin
Result := true ;
Exit;
end;
end ;
end ;
End;
Cirec
Messages postés3833Date d'inscriptionvendredi 23 juillet 2004StatutModérateurDernière intervention18 septembre 202250 11 juin 2007 à 23:30
Salut,
voici un truc que
j'ai fais il y a quelques temps déjà (pour le forum) et ça devrait te
convenir et en plus tu utilises le même nom de fonction que moi
function CheckForBlankText(Container : TWinControl) : Boolean;
var i : Integer;
begin With Container do If HasParent Then for i := 0 to ControlCount-1 do begin if (Controls[i] is TEdit) then begin Result : (Controls[i] <gras>as TEdit).Text</gras> '';
if Result then Exit;
end;
end Else for i : = 0 to ComponentCount-1 do begin if (Components[i] is TEdit) then begin Result :(Components[i] as TEdit).Text '';
if Result then Exit;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
Const aMsg : Array[Boolean] of String = (' il n''y a pas d''Edit Vide', ' il y a au moins un TEdit Vide');
begin
ShowMessage('Dans Panel1' + aMSG[CheckForBlankText(Panel1)]);
ShowMessage('Dans GroupBox1' + aMSG[CheckForBlankText(GroupBox1)]);
ShowMessage('Dans Form1' + aMSG[CheckForBlankText(Self)]);
end;
@+
Cirec