?
Solved

Create a customer TPanel component

Posted on 2007-03-30
5
Medium Priority
?
328 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

762 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