Solved

Show a label on a form created at runtime

Posted on 1998-06-18
2
168 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 166
Delphi: how to implement a User Shortcut mapper? 1 119
find a node in VST 2 73
Tvertscrollbox like a whatsapp layout 5 35
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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