Bonjour,

je voudrais réaliser un composant qui soit un merge entre une TButtonedEdit et un TListView.
La class serait héritée du TButtonedEdit et lorsque l'on click sur le boutton de droite du composant, le TListView apparaitrait en dessous.

J'ai crée le composant, seulement voila, le TListView n'apparait pas...
Si le parent du TListView est le TButtonedEdit alors il s'affiche mais à l'intérieur du TButtonedEdit (normal puisqu'il est son parent).
Par contre, si je mets dans le parent Self.Parent à la place de Self, rien ne s'affiche...

Je me doute qu'il doit y avoir qlq part des informations a fournir sur les données à rafraichir mais je sèche complètement sur comment faire

Voici le code du composant :
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
 
unit ButtonEditListView;
 
interface
 
uses ComCtrls, ExtCtrls, Classes, Controls, Graphics;
 
type
 
  TLVSelectItemEvent = procedure(Sender: TObject; Item: TListItem;
    Selected: Boolean) of object;
 
  TButtonEditListView = class(TButtonedEdit)
  private
 
    IconRightButton : TIcon;
 
    fOnListViewSelectItem : TNotifyEvent;
    fOnOpenListView : TNotifyEvent;
 
    function fReadColumns : TListColumns;
    procedure fWriteColumns(Cols : TListColumns);
 
    function fReadItems : TListItems;
    procedure fWriteItems(Items : TListItems);
 
    procedure ShowListView(Owner: TObject);
    procedure HideListView(Sender: TObject; Item: TListItem;
    Selected: Boolean);
 
    function GetOnOpenListView : TNotifyEvent;
    procedure SetOnOpenListView(const Value: TNotifyEvent);
 
  protected
 
  public
    ListView : TListView;
    fImageList : TImageList;
 
    //property EnableListView
 
    constructor Create(AOwner : TComponent); Override;
    destructor Destroy; override;
  published
 
   // Property Columns : TlistColumns read fReadColumns write fWriteColumns;
   // Property Items : TListItems read fReadItems write fWriteItems;
 
    Property OnListViewSelectItem : TNotifyEvent read fOnListViewSelectItem write fOnListViewSelectItem;
    property OnOpenListView : TNotifyEvent read fOnOpenListView write fOnOpenListView;
 
  end;
 
procedure Register;
 
implementation
 
//{$R *.res}
 
procedure Register;
begin
  RegisterComponents('GDB Caché', [TButtonEditListView]);
end;
 
constructor TButtonEditListView.Create(AOwner : TComponent);
begin
  Inherited;
  ListView := TListView.Create(Self);
  ListView.Parent := Self.Parent;
  ListView.Top := 2;
  ListView.Left := 2;
  ListView.Width := 100;
  ListView.Height := 100;
 
  // Create and give it position
  {
  ListView.Top := Self.Top + Self.Height;
  ListView.Left := Self.Left;
  ListView.Width := Self.Width;
  ListView.Height := Self.Height;
  }
 
  ListView.RowSelect := True;
  ListView.ViewStyle := vsReport;
  ListView.ShowColumnHeaders := False;
  //ListView.BevelOuter := bvnone;
  ListView.Enabled := False;
  ListView.Visible := False;
  ListView.BringToFront;
 
  Invalidate;
 
  ListView.OnSelectItem := HideListView;
 
  Self.OnRightButtonClick := ShowListView;
 
  // Configure the icons in the right button
  IconRightButton := TIcon.Create;
  IconRightButton.LoadFromResourceName(HInstance,'DOWN2');
 
  fImageList := TImageList.Create(nil);
  fImageList.AddIcon(IconRightButton);
 
  Self.Images := fImageList;
  Self.RightButton.Enabled := True;
  Self.RightButton.Visible := True;
  Self.RightButton.DisabledImageIndex := 0;
  Self.RightButton.HotImageIndex := 0;
  Self.RightButton.ImageIndex := 0;
  Self.RightButton.PressedImageIndex := 0;
 
  Self.SetBounds(50,50,100,100);
 
end;
 
destructor TButtonEditListView.Destroy;
begin
  ListView.Destroy;
  IconRightButton.Destroy;
  fImageList.Destroy;
  Inherited;
end;
 
//******************************************************************************
function TButtonEditListView.fReadColumns : TListColumns;
begin
  //Result := ListView.Columns;
end;
 
procedure TButtonEditListView.fWriteColumns(Cols : TListColumns);
begin
  //ListView.Columns := Cols;
end;
 
//******************************************************************************
function TButtonEditListView.fReadItems : TListItems;
begin
  //Result := ListView.Items;
end;
 
procedure TButtonEditListView.fWriteItems(Items : TListItems);
begin
  //ListView.Items := Items;
end;
 
//******************************************************************************
procedure TButtonEditListView.ShowListView(Owner: TObject);
begin
  if Assigned(OnOpenListView) then OnOpenListView(Self);
 
  ListView.Top := 2;
  ListView.Left := 5;
  ListView.Width := 500;
  ListView.Height := 500;
  ListView.Enabled := True;
  ListView.Visible := True;
  ListView.BringToFront;
 
  Invalidate;
end;
 
procedure TButtonEditListView.HideListView(Sender: TObject; Item: TListItem;
    Selected: Boolean);
begin
  if Assigned(OnListViewSelectItem) then OnListViewSelectItem(Self);
  ListView.Enabled := False;
  ListView.Visible := False;
end;
 
//******************************************************************************
function TButtonEditListView.GetOnOpenListView : TNotifyEvent;
begin
  ShowListView(nil);
end;
 
//******************************************************************************
procedure TButtonEditListView.SetOnOpenListView(const Value: TNotifyEvent);
begin
  inherited;
end;
 
end.
Toute piste est bonne à prendre