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

Events in via ElementHost in VB.NET

2 Answers 114 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Tim Carmichael
Top achievements
Rank 1
Tim Carmichael asked on 16 Dec 2008, 11:47 PM
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 Answers, 1 is accepted

Sort by
0
Tim Carmichael
Top achievements
Rank 1
answered on 17 Dec 2008, 10:12 PM
'//------------- 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?
0
Rosi
Telerik team
answered on 18 Dec 2008, 08:46 AM
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,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Carousel
Asked by
Tim Carmichael
Top achievements
Rank 1
Answers by
Tim Carmichael
Top achievements
Rank 1
Rosi
Telerik team
Share this question
or