Solved

Show a label on a form created at runtime

Posted on 1998-06-18
2
166 Views
Last Modified: 2010-04-04
At runtime a have created a form. How can I create a label on this form at runtime so a can display a message.

0
Comment
Question by:lpd
2 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 200 total points
ID: 1353863
lpd,

 Put a label on the form, set it's caption to blank (nothing) so it does not show any text. At runtime simply assign a value to the Caption of the Label with something like:

Label1.Caption := 'Hi There!';

Good luck with your project!
Pegasus
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1353864
Okay...you can also create your label at runtime...



type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Label1 : TLabel;
    procedure MyClick(Sender: TObject);
  end;

var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.MyClick(Sender: TObject);
begin
  ShowMessage('Hello');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Label1 := TLabel.create(self);
with Label1 do
begin
  parent := self;  //or the form/panel...
  top := 10;
  left := 20;
  caption := 'My Message';
  onclick := myClick;
  show;
end;
end;

end.

Rick

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now