Dynamicaly assigning methods lazarus / 8-Other ---------------------------------------------------------------------- Adam.Pilorz · 2004-11-14 14:48 I have a problem. I'm creating a dynamic button (for example like that: Code: [Select]var MyButton: TButton; ... MyButton:=TButton.Create(Self); MyButton.Top:=2; MyButton.Left:=2; MyButton.Width:=200; MyButton.Height:=28; MyButton.Caption:='MyButton';) And now how to assign a method to a dynamic button? Such thing should work: Code: [Select]MyButton.OnClick:=MyForm.MyButtonClick; Unfortunately, it doesn't do anything except halting compilation and calling an error: Wrong number of parameters... Of course, compiler is trying to assign a return value of MyButtonClick method. How to solve this problem?? ---------------------------------------------------------------------- mikiwoz · 2004-11-14 19:05 MyButton.OnClick:=@WhateverIsTheMethodsName should do the trick. I had the same problem and that was the solution. ---------------------------------------------------------------------- Adam.Pilorz · 2004-11-14 21:45 Unfortunately, it ends with an error: Incopatible types: got "
" expected "