Unable to access event base field

I am trying to fire the TButton Click event from the doubleclick TListBox event by simply calling:

Button1.Click; 

I can always do this under Delphi XE and the version below, but now it causes an error in Delphi Prism. The error message "Unable to access the base field of the event." So, how could you trigger an event from one event of another control, such as a TListBox?

eg:

 method UnitSelectDialog.UnitListBox_DoubleClick(sender: System.Object; e: System.EventArgs); begin Okbtn.Click; end; 

The above code is the same as if you clicked the OK Tbutton button on the form.

+7
source share
2 answers

I am not familiar with Prism, but for me it looks like a WinForms button. If so, you can call PerformClick .

 OKbtn.PerformClick; 
Events

.net is much more complicated than VCL events. Most importantly, they are multi-sheeted, which means that multiple handlers can be connected. One consequence of this is that triggering events are much more complex.

+5
source

if you define your own class, the second option is to set a public "raise" handler for the event, for example

 event Click: ClickEventhandler; public raise; 

this causes the compiler to make the method publicly available so that other classes can call "Click ()" to trigger the event. (of course, any other impersonal visibility also works).

0
source

All Articles