Events in via ElementHost in VB.NET

3 posts, 0 answers
  1. Tim Carmichael
    Tim Carmichael avatar
    15 posts
    Member since:
    Sep 2008

    Posted 16 Dec 2008 Link to this post

    Hi there,

    I'm using the RadCarousel via an ElementHost control in a VB.NET application.  The items I am adding to the carousel are inherited from Carouseltem and expose a few extra properties for convenience.

    Anyway, the items display great, but one thing I can't get to happen is to monitor any events for the items, they just don't seem to get raised.  I would like to know when an item has been clicked so I can respond to the event but nothing is currently working.

    Alternatively I would like to know when an items IsCurrent flag is raised as this should provide the same functionality.

    Any ideas how I latch onto these events?
  2. Tim Carmichael
    Tim Carmichael avatar
    15 posts
    Member since:
    Sep 2008

    Posted 17 Dec 2008 Link to this post

    '//------------- Adding item to carousel and handler to mousedown event  
    Dim pPImItem As PlaylistItem = PlaylistItem.fromID3TagReader(pITRItem)  
    Call cRClCarousel.Items.Add(pPImItem)  
    AddHandler pPImItem.MouseDown, AddressOf pop  
    '//-------------  Handler  
    Private Sub pop(ByVal oSender As ObjectByVal oArgs As Windows.Input.MouseButtonEventArgs)  
            '//This never gets raised  
            Console.WriteLine(CType(cRClCarousel.CurrentItem, PlaylistItem).title)  
    End Sub 

    The above is an example of what I'm doing that is not working.

    As mentioned before, PlaylistItem inherits from CarouselItem

    I can attach events to the carousel itself and they work fine, but as it doesn't have many events available, including the standard events that you would expect for a list control, such as "CurrentItemChanged" etc. I am having to try to attach to the individual items themselves.

    Any ideas why the event never gets raised?
  3. Rosi
    Rosi avatar
    2529 posts

    Posted 18 Dec 2008 Link to this post

    Hi Tim,

    Thanks for your interest in out RadCarousel control.

    I suggest you subscribe to the CarouselItem's MouseDown event by the following way:
    Me.AddHandler(CarouselItem.MouseDownEvent, New MouseButtonEventHandler(Example_MouseDown), True)  

    Then, in the EventHandler of MouseDown event you can get the CurrentItem:
    Sub Example_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Input.MouseButtonEventArgs)  
        Dim currentItem As Object = RadCarousel1.CurrentItem  
    End Sub 

    Hope this helps.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top