This is a migrated thread and some comments may be shown as answers.

Get click event handlers of a RadTileElement

4 Answers 181 Views
Panorama
This is a migrated thread and some comments may be shown as answers.
Raniere Muniz
Top achievements
Rank 1
Raniere Muniz asked on 12 Mar 2013, 10:58 AM
Hello,

How can I get the list of all the event handlers (delegates) associated with the Click event on a RadTileElement in Panorama control using reflection?

I should implement a proxy class that add or remove handlers on Click event.

Something like this:

private event EventHandler _eventProxy;
...
var _handlers = GetEventHandlers(radTileElement, "Click");
foreach (var handler in _handlers)
{
  _eventProxy += (EventHandler)handler;
}

I could do it with normal Controls but not with RadTileElement in Panorama.

Thank you in advance,

Raniere

4 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 15 Mar 2013, 10:02 AM
Hello Raniere,

Thank you for writing.

To get the handlers added to the Click event of an element you can use the following method:
private Delegate[] GetEventHandlers(object instance)
{
    FieldInfo eventsField = typeof(DisposableObject).GetField("events", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
    EventHandlerList list = eventsField.GetValue(instance) as EventHandlerList;
    FieldInfo keyField = typeof(RadItem).GetField("MouseClickEventKey", BindingFlags.Static | BindingFlags.NonPublic);
    object eventKey = keyField.GetValue(instance);
    EventHandler eventDelegate = (EventHandler)list[eventKey];
 
    if (eventDelegate == null)
    {
        return null;
    }
 
    return eventDelegate.GetInvocationList();
}
I hope this is useful. Should you have further questions, I would be glad to help.

Kind regards,
Ivan Petrov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Raniere Muniz
Top achievements
Rank 1
answered on 22 Mar 2013, 11:28 AM
Great!

It works perfectly!

Thaks!

Raniere
0
BesT LoLo
Top achievements
Rank 2
answered on 19 Dec 2013, 07:59 AM
Hi All;
Can i add an event (e.g: onmousedown) to a RadBinaryImage inside UpdatePanel inside radgrid ?, and use this event on code behind?

Best Regards

BesT LoLo
0
Ivan Petrov
Telerik team
answered on 20 Dec 2013, 02:33 PM
Hello,

This is the WinForms suite forum. Any questions related to other suites should be opened in the corresponding forum section. It seems your questions is about our ASP.NET AJAX suite. If this is the case please post your questions in the following forum section - ASP.NET AJAX.

I hope this will be useful. Feel free to write back with further questions.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Panorama
Asked by
Raniere Muniz
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Raniere Muniz
Top achievements
Rank 1
BesT LoLo
Top achievements
Rank 2
Share this question
or