performing procedure onclick of array element - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

performing procedure onclick of array element

micahmicah Posts: 4Member
Hi,

I have a for loop that creates a series of labels, captioned with the file name of a series of files. When each is clicked, I want it to perform the procedure LoadEntry(I), where I is the integer value of the entry no to load. My procedure LoadEntry works fine, but there is an error in the code below

//print a list of the last 20 entries
for I := 1 to StrToInt(latestentry()) do
begin
if (I > 20) then
break;
entryno:=StrToInt(latestentry())-I+1;
LabelArray[I] := TLabel.Create(Self);
LabelArray[I].Parent := Self;
LabelArray[I].Left := 408;
LabelArray[I].Top := 136 + 15 * I;
LabelArray[I].OnClick:=LoadEntry(entryno);
fileurl := 'entries/'+IntToStr(entryno)+'.jnl';
LabelArray[I].Caption := 'Entry #'+IntToStr(entryno)+': '+DateTimeToStr(FileDateToDateTime(FileAge(fileurl)));;
end;

The error is in the line with the onClick handler. Any ideas?

Many thanks,

Micah

Comments

  • injektiloinjektilo Posts: 113Member
    you can only assign a TNotifyEvent to the OnClick. if you need the number then i'd suggest you'd use the TEdit(Sender).Tag
  • micahmicah Posts: 4Member
    : you can only assign a TNotifyEvent to the OnClick. if you need the number then i'd suggest you'd use the TEdit(Sender).Tag
    :
    Can you give me an idea of how to do this?
  • micahmicah Posts: 4Member
    : : you can only assign a TNotifyEvent to the OnClick. if you need the number then i'd suggest you'd use the TEdit(Sender).Tag
    : :
    : Can you give me an idea of how to do this?
    :
    Actually, I got it!
Sign In or Register to comment.