1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

How to link a component's event to a procedure defined in datamodule at design-time

Discussion in 'Delphi Help&Requests' started by Hwau, Apr 4, 2015.

  1. Hwau
    Offline

    Hwau DF Member

    Hello!
    First of all, I'm not skilled about this forum's usage, so, I hope it's the right section for a thread like this.
    I would like to know if there's any way to link a component's event (As <TButton>.OnClick) to a procedure defined in a datamodule (At design-time).
    At the moment, I'm doing this at runtime:

    MyButton.OnClick := MyDataModule.MyOnClickEvent;

    The goal would be that to get MyDataModule.MyOnClickEvent proposed in the dropdown lists of the Object Inspector Window.
    Thanks in advance to all who will share their knowledge :D
     
  2. galdariah
    Offline

    galdariah DF Junior

    You are doing it right!
    The only way to select on dropdown on ObjInsp, is to have this procedure in some component inside the datamodule, but this is a workaround. Don't change ur code, it's perfect.
     
  3. BadBlue
    Offline

    BadBlue DF Senior

    RE: How to

    Hi,

     If you double click on the <TButton>.OnClick you will get the onclick event procedure prototype.
     Just create a procedure with the same arguments on the public section of the datamodule, add-it the the <TButton> form uses and it should appear on the Object Inspector Window drop down.

    Regards
     
  4. Hwau
    Offline

    Hwau DF Member

    Hello! Thanks for your answer but unfortunately, just datamodule's components appears in dropdown lists, events seem to be hidden for some reason :(
     
  5. BadBlue
    Offline

    BadBlue DF Senior

    RE:

    Hi,

     Sorry.
     Use a action list to accomplish it.

     I attached a simple project as a demo.

    Regard
     

    Attached Files:

  6. Hwau
    Offline

    Hwau DF Member

    Hi, 
    It works with the TButton.OnClick event but my goal would be that to do the same thing also for other kind of events/components... :(
    (The only way I found consists in define all events on a parent-form, but I was hoping there was a cleaner solution)
     
  7. BadBlue
    Offline

    BadBlue DF Senior

    RE:

    Hi,

     It should be supported by all component's that implement the action property.
     The are more components, like TCheckBox, TRadioButton, etc.

    Regards
     
  8. fajarpriyadi0815
    Online

    fajarpriyadi0815 Guest

    RE:

    example : I can Use Ttimer in my datamodule

    just add Uses

    uses
      SysUtils, Windows, Forms, Classes, Dialogs, StdCtrls,ExtCtrls, ImgList, Controls, XPMan,DB ;

    example


     
  9. Hwau
    Offline

    Hwau DF Member

    Ok but I would like to find a solution that works for all components.
    (Also thirdy party components...)
    [hr]
     
  10. fajarpriyadi0815
    Online

    fajarpriyadi0815 Guest

    RE:

    just add this

      SysUtils, Windows, Forms, Classes, Dialogs, StdCtrls,ExtCtrls, ImgList, Controls, XPMan,DB ;

    in datamodule uses
     

Share This Page