Get click event handlers of a RadTileElement

5 posts, 0 answers
  1. Raniere Muniz
    Raniere Muniz avatar
    2 posts
    Member since:
    Apr 2009

    Posted 12 Mar 2013 Link to this post

    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
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 15 Mar 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Raniere Muniz
    Raniere Muniz avatar
    2 posts
    Member since:
    Apr 2009

    Posted 22 Mar 2013 Link to this post

    Great!

    It works perfectly!

    Thaks!

    Raniere
  5. BesT LoLo
    BesT LoLo avatar
    11 posts
    Member since:
    Dec 2013

    Posted 19 Dec 2013 Link to this post

    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
  6. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 20 Dec 2013 Link to this post

    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 >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready