Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to pick from a list of TPanels in a TListBox and display the selected panel Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
26-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
94
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to pick from a list of TPanels in a TListBox and display the selected panel

Answer:

1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7     Dialogs, ExtCtrls, StdCtrls;
8   
9   type
10    TForm1 = class(TForm)
11      ListBox1: TListBox;
12      procedure ListBox1Click(Sender: TObject);
13    private
14      { Private declarations }
15      FPanelList: TList;
16      FActivePanel: TPanel;
17    public
18      { Public declarations }
19      constructor Create(AOwner: TComponent); override;
20      destructor Destroy; override;
21    end;
22  
23  var
24    Form1: TForm1;
25  
26  implementation
27  
28  {$R *.DFM}
29  
30  {TForm1}
31  
32  constructor TForm1.Create(AOwner: TComponent);
33  var
34    i: integer;
35    TempPanel: TPanel;
36  begin
37    inherited;
38    FPanelList := TList.Create;
39    for i := 0 to 20 do
40    begin
41      TempPanel := TPanel.Create(self);
42      TempPanel.Caption := 'TPanel' + IntToStr(i);
43      Listbox1.Items.Add(TempPanel.Caption);
44      FPanelList.Add(TempPanel);
45    end;
46  end;
47  
48  destructor TForm1.Destroy;
49  var
50    i: integer;
51  begin
52    for i := FPanelList.Count - 1 downto 0 do
53      TPanel(FPanelList[i]).Free;
54    FPanelList.Free;
55    inherited;
56  end;
57  
58  procedure TForm1.ListBox1Click(Sender: TObject);
59  begin
60    if FActivePanel <> nil then
61      FActivePanel.Parent := nil;
62    FActivePanel := FPanelList[ListBox1.ItemIndex];
63    FActivePanel.Parent := self;
64  end;
65  
66  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC