Bonjour a tous,
j'ai encore du mal a comprendre le remplissage des listview par programmation
j'ai mis sur ma fiche un TImageList avec plusieurs images
Ainsi qu'une ListView où je souhaite remplir l'image , le detail et text.
Je ne peux utiliser de boucle
A l’exécution les 2 items apparaissent mais sans texte et image.
Voici le code de la fiche (j'ai remplacer par des XXX le code des images pb de droits)
voici le code pascal ici dans un onform mais j'ai aussi essayer dans un oncreate
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 object Form_FEN_Horaires_TAB: TForm_FEN_Horaires_TAB Left = 0 Top = 0 BorderIcons = [] Caption = 'CalHeb' ClientHeight = 536 ClientWidth = 612 Fill.Color = xFF4285F4 Fill.Kind = Solid FormFactor.Width = 320 FormFactor.Height = 480 FormFactor.Devices = [Desktop] OnShow = FormShow DesignerMasterStyle = 3 object ListView2: TListView ItemAppearanceClassName = 'TImageListItemBottomDetailAppearance' ItemEditAppearanceClassName = 'TImageListItemBottomDetailShowCheckAppearance' HeaderAppearanceClassName = 'TListHeaderObjects' FooterAppearanceClassName = 'TListHeaderObjects' Anchors = [] Position.X = 25.000000000000000000 Position.Y = 129.000000000000000000 Size.Width = 300.000000000000000000 Size.Height = 305.000000000000000000 Size.PlatformDefault = False TabOrder = 0 end object Label1: TLabel Position.X = 136.000000000000000000 Position.Y = 40.000000000000000000 Text = 'Label1' TabOrder = 2 end object Label2: TLabel Position.X = 136.000000000000000000 Position.Y = 72.000000000000000000 Text = 'Label2' TabOrder = 3 end object Label3: TLabel Position.X = 136.000000000000000000 Position.Y = 96.000000000000000000 Text = 'Label3' TabOrder = 4 end object ImageList1: TImageList Source = < item MultiResBitmap.Height = 51 MultiResBitmap.Width = 68 MultiResBitmap.LoadSize = 0 MultiResBitmap = < item Width = 68 Height = 51 PNG = { XXX} FileName = 'E:\DELPHI\CalHeb_Delphi\ImagesList\coucher_du_soleil.jpg' end> Name = 'coucher_du_soleil' end item MultiResBitmap.Height = 53 MultiResBitmap.Width = 68 MultiResBitmap.LoadSize = 0 MultiResBitmap = < item Width = 68 Height = 53 PNG = { XXX} FileName = 'E:\DELPHI\CalHeb_Delphi\ImagesList\corban.png' end> Name = 'corban' end item MultiResBitmap.Height = 68 MultiResBitmap.Width = 68 MultiResBitmap.LoadSize = 0 MultiResBitmap = < item Width = 68 Height = 68 PNG = { XXX} FileName = 'E:\DELPHI\CalHeb_Delphi\ImagesList\FLS12460.png' end> Name = 'Time' end item MultiResBitmap = < item Width = 68 Height = 45 PNG = { XXX} FileName = 'E:\DELPHI\CalHeb_Delphi\ImagesList\midi.jpg' end> Name = 'midi' end item MultiResBitmap = < item Width = 68 Height = 46 PNG = { XXX} FileName = 'E:\DELPHI\CalHeb_Delphi\ImagesList\Lever_du_soleil.jpg' end> Name = 'Lever_du_soleil' end item Layers = < item Name = 'coucher_du_soleil' SourceRect.Right = 68.000000000000000000 SourceRect.Bottom = 51.000000000000000000 end> end item Layers = < item Name = 'midi' SourceRect.Right = 68.000000000000000000 SourceRect.Bottom = 45.000000000000000000 end> end item Layers = < item Name = 'Lever_du_soleil' SourceRect.Right = 68.000000000000000000 SourceRect.Bottom = 46.000000000000000000 end> end Left = 336 Top = 40 end end
Pour information je suis en delphi 10.3.3 community
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 unit FEN_Horaires_TAB; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base, System.ImageList, FMX.ImgList, FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListView; type TForm_FEN_Horaires_TAB = class(TForm) ListView2: TListView; Label1: TLabel; Label2: TLabel; Label3: TLabel; ImageList1: TImageList; procedure FormShow(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form_FEN_Horaires_TAB: TForm_FEN_Horaires_TAB; implementation {$R *.fmx} procedure TForm_FEN_Horaires_TAB.FormShow(Sender: TObject); var sJour: string; LItem: TListViewItem; AListItemBitmap: TListItemImage; AListItemText: TListItemText; begin sJour := '1255'; // début programme // affichage de la listview ListView2.BeginUpdate; // style non appliqué dans oncreate ListView2.ApplyStyleLookup; // efface la liste ListView2.Items.Clear; // ajoute un item a la liste LItem := ListView2.Items.Add; AListItemBitmap := LItem.Objects.FindObjectT<TListItemImage>('Image'); AListItemText := LItem.Objects.FindObjectT<TListItemText>('Detail'); if Assigned(AListItemBitmap) AND Assigned(AListItemText) then begin AListItemText.Text := 'premiere image :'; AListItemBitmap.ImageIndex := 1; end; LItem := ListView2.Items.Add; AListItemBitmap := LItem.Objects.FindObjectT<TListItemImage>('Image'); AListItemText := LItem.Objects.FindObjectT<TListItemText>('Detail'); if Assigned(AListItemBitmap) AND Assigned(AListItemText) then begin AListItemText.Text := 'deuxieme image :'; AListItemBitmap.ImageIndex := 2; end; ListView2.EndUpdate; end; end.
Si je suis obligé a chaque fois de demander de l'aide pour un truc qui a l'air si simple
Je crois que je vais essayer de trouver un autre langage que Delphi.
Partager