Vider ces edits et combobox en une fois. Au lieu de...
Leader2000
Messages postés184Date d'inscriptionmercredi 24 mai 2006StatutMembreDernière intervention28 août 2015
-
10 janv. 2009 à 11:52
Cirec
Messages postés3833Date d'inscriptionvendredi 23 juillet 2004StatutModérateurDernière intervention18 septembre 2022
-
10 janv. 2009 à 21:38
Bonjour!
Les codes colorés de rouge me permettent de vides mes edits et combobox. Je voulais changer de methode: comment pourrai-je vider ceux-ci qu'avec une ligne de commande.
with ADORegisApreensDiam do
ADORegisApreensDiam.Append;
ADORegisApreensDiam.FieldValues['province']:= provinciaRegistoApreensoesDiamantes.Text;
ADORegisApreensDiam.FieldByName('mois').AsString:= mesRegisApreensDiamantes.Text;
ADORegisApreensDiam.FieldByName('anee').AsString:= anoRegisApreensDiamantes.Text;
ADORegisApreensDiam.Post;
provinceRegistoApreensoesDiamantes.Text:= '';
moisRegisApreensDiamantes.Text:= '';
aneeRegisApreensDiamantes.Text:= '';
Cirec
Messages postés3833Date d'inscriptionvendredi 23 juillet 2004StatutModérateurDernière intervention18 septembre 202250 10 janv. 2009 à 21:38
Salut,
c'est tout simple
Ajouer "TypInfo" au Uses
type
Tfrm_Main = class(TForm)
...
private
{ Déclarations privées }
procedure SetPropertys(ClassName: String;
SomeProperty: array of string; Value: array of Variant);
implementation
procedure Tfrm_Main.SetPropertys(ClassName: String; SomeProperty: array of string; Value: array of Variant);
var
i, j: integer;
PropInfo: PPropInfo;
Component: TComponent;
begin
for i := 0 to ComponentCount - 1 do
begin
Component := Components[i];
if (Component is TControl) and ((Component.ClassName = ClassName)
or (ClassName = 'AllComponents')) then
Begin
if High(SomeProperty) = High(Value) Then
for j := 0 to High(SomeProperty) do
Begin
PropInfo := GetPropInfo(Component.ClassInfo, SomeProperty[j]);
if Assigned(PropInfo) then
SetPropValue(Component, PropInfo.Name, Value[j]);
End
else
for j := 0 to High(SomeProperty) do
Begin
PropInfo := GetPropInfo(Component.ClassInfo, SomeProperty[j]);
if Assigned(PropInfo) then
SetPropValue(Component, PropInfo.Name, Value[0]);
end;
end;
end;
end;
Utilisation
SetPropertys('AllComponents',['Text'],['']);
si tu mets "Caption" à la place de "Text" la portée sera plus grande
ou
SetPropertys('TEdit',['Text'],['']);
ou
SetPropertys('TComboBox',['Text'],['']);
on peut aussi l'étendre à plusieurs propriétés:
SetPropertys('AllComponents', ['Enabled', 'Checked', 'Text'],[ True, False, '']);
SetPropertys('AllComponents', ['Enabled', 'Checked'],[ True]);