Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.