Bonjour,
J'ai un peu de mal à comprendre pourquoi la propriété readonly du composant Tmemo ne se met fait pas son travail.
L'objectif est de gérer la permission de modifier ou non le memo. cela marche pour les autres composants Tedit et TdateEdit (Merci Chris37).
Voici le code :
Pour info memo1 est un memo test pour lire les valeur de readonly son tag est à zero le nom du memo concerné est bnf_memo et son tag est bien à 5.
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 // Annulation d'une saisie ou d'une modification procedure Tf_benef.bt_annulerClick(Sender: TObject); Var I : Integer; begin memo1.Caption:=''; // Chargement des valeurs initiales de la table >> TEdit // Y a t'il un enregistrement ? If v_recid<>0 Then for i := 0 to pred(f_benef.ComponentCount) do Begin If (f_benef.Components[i].tag=5) Then Begin // Tedit if (f_benef.Components[i] is TEdit) Then Begin (f_benef.Components[i] as TEdit).Text := f_benef.sql_benef_rec.fieldByName(f_benef.Components[i].Name).asString; (f_benef.Components[i] as TEdit).ReadOnly :=True; memo1.Caption:= memo1.Caption + ' Edit ' + BoolToStr((f_benef.Components[i] as TEdit).ReadOnly); End; // Tdatedit if (f_benef.Components[i] is TDateEdit) Then Begin (f_benef.Components[i] as TDateEdit).Date := f_benef.sql_benef_rec.fieldByName(f_benef.Components[i].Name).AsDateTime; (f_benef.Components[i] as TDateEdit).ReadOnly :=True; memo1.Caption:=memo1.Caption + ' date ' + BoolToStr((f_benef.Components[i] as TDateEdit).ReadOnly); End; // Tmemo if (f_benef.Components[i] is TMemo) Then Begin (f_benef.Components[i] as TMemo).Text := f_benef.sql_benef_rec.fieldByName(f_benef.Components[i].Name).asString; (f_benef.Components[i] as TMemo).ReadOnly :=True; memo1.Caption:=memo1.Caption + ' memo ' + BoolToStr((f_benef.Components[i] as TMemo).ReadOnly); End; End; End; // Gestion de l'affichage // Annulation du mode modification pan_menu_navigator.Color:=clCream; bt_creer.Visible:=True; bt_supprimer.Visible:=True; bt_quitter1.Visible:=True; bt_modifier.Visible:=True; bt_prec.Visible:=True; bt_suiv.Visible:=True; bt_annuler.Visible:=False; bt_valider.Visible:=False; end; // Modification d'un enregistrement procedure Tf_benef.bt_modifierClick(Sender: TObject); Var i : Integer; begin memo1.Caption:=''; // Donne la permission de modifier les champs for i := 0 to pred(f_benef.ComponentCount) do Begin If (f_benef.Components[i].tag=5) Then Begin if (f_benef.Components[i] is TEdit) Then Begin (f_benef.Components[i] as TEdit).ReadOnly :=False; memo1.Caption:= memo1.Caption + ' edit ' + BoolToStr((f_benef.Components[i] as TEdit).ReadOnly); End; if (f_benef.Components[i] is TDateEdit) Then Begin (f_benef.Components[i] as TDateEdit).ReadOnly :=False; memo1.Caption:=memo1.Caption + ' dateedit ' + BoolToStr((f_benef.Components[i] as TDateEdit).ReadOnly); End; if (f_benef.Components[i] is TMemo) Then begin (f_benef.Components[i] as TMemo).ReadOnly :=False; memo1.Caption:=memo1.Caption + 'memo ' + BoolToStr((f_benef.Components[i] as TMemo).ReadOnly); end; End; End; // Gestion de l'affichage // Mise en place du mode modification pan_menu_navigator.Color:=clRed; bt_creer.Visible:=False; bt_supprimer.Visible:=False; bt_quitter1.Visible:=False; bt_modifier.Visible:=False; bt_prec.Visible:=False; bt_suiv.Visible:=False; bt_annuler.Visible:=True; bt_valider.Visible:=True; end;
Ce qui me surprend d'autant plus c'est que le remplissage du mémo s'effectue bien.
Sans doute une étourderie mais je tourne autour depuis pas mal de temps alors si vos neurones sont plus éveillés que les miens...
Merci d'avance.
Eric
Partager