Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create a customer TPanel component

Posted on 2007-03-30
5
Medium Priority
?
331 Views
Last Modified: 2013-11-23
Hi all,

I am trying to create a custom TPanel component.
On the panel i require another panel at the top and a Listview at the bottom.
The size of the main panel is only going to be 100x100.

I need it this way as I need 26 of these components on 1 page, plus I can store specific objects against each of the components.

Having trouble getting this to work so any help appreciated.
0
Comment
Question by:mikelittlewood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 18823271
Maybe Frame is a good choice?
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 18823324
I don't know he he .. never has to make a component within a component   :o)
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 18823372
Personally I would rather have an example of an extended panel than using a frame if someone had some code.
0
 
LVL 17

Expert Comment

by:mokule
ID: 18823373
So try to create a frame.
File | New | Frame
place any component on it
And then on each form of Your application You can place using Frame component from Standard components
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 375 total points
ID: 18833024
here's an example I wrote for you.
You can easily turn this into a VCL (so you can use it in design mode) by adding a "register" method

unit Unit1;

interface


uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, ComCtrls, StdCtrls;

type TMyPanel = class(TPanel)
  public
    TopPanel: TPanel;
    ListView: TListView;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
end;

type
  TForm1 = class(TForm)
    Button_Make26Panels: TButton;
    procedure Button_Make26PanelsClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ TMyPanel }

constructor TMyPanel.Create(AOwner: TComponent);
const
  def_mainpanelheight = 100;
  def_mainpanelwidth = 100;
  def_toppanelheight = 50;
begin
  inherited Create(AOwner);
  self.Height := def_mainpanelheight;
  self.Width := def_mainpanelwidth;
  TopPanel := TPanel.Create(self);
  with TopPanel do
  begin
    Parent := self;
    Height := def_toppanelheight;
    Align := alTop;
  end;
  ListView := TListView.Create(self);
  with ListView do
  begin
    Parent := self;
    Align := alClient;
  end;
end;

destructor TMyPanel.Destroy;
begin
  if assigned(TopPanel) then FreeAndNil(TopPanel);
  if assigned(ListView) then FreeAndNil(ListView);
  inherited Destroy;
end;

procedure TForm1.Button_Make26PanelsClick(Sender: TObject);
var
  col, row: integer;
  newpanel: TMyPanel;
  i: integer;
begin
  i := 0;
  for col := 1 to 13 do
    for row := 1 to 13 do
    begin
      inc(i);
      newpanel := TMyPanel.Create(Form1);
      with newpanel do
      begin
        Left := (col-1) * 102;
        top := (row-1) * 102;
        TopPanel.Caption := IntToStr(i);
        Parent := Form1;
      end;
    end;
end;

end.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question