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

odd indexing of RadImageitems in Rad Carousel

3 Answers 123 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
George C.
Top achievements
Rank 2
Iron
Veteran
George C. asked on 24 Jul 2020, 12:02 PM

Greetings,

I have 2 controls  :

1-  Rad Carousel (name =  Slideshow) , with 5 Image items , each image is labeled on with its corresponding index.

2- Label1

 

I wrote the code below to check the selected item of Rad Carousel control (Using a very simple method : showing the selected index value in form of a label's text)

 

Private Sub SlideShow_SelectedItemChanged(sender As Object, e As EventArgs) Handles SlideShow.SelectedItemChanged
 
           Label1.Text = SlideShow.SelectedIndex
 
 
   End Sub
 
   Private Sub SlideShow_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SlideShow.SelectedIndexChanged
 
           Label1.Text = SlideShow.SelectedIndex
 
       End If
 
   End Sub

 

I attached a gif file that illustrates the issue with odd indexing.

Surprisingly,  When I switch between items moving backward and forward, the selected item's index, shown in the label, doesn't match with the real indexing of the item . As you can see, clicking on the right arrow of the Rad Carousel seems to work just fine and indexing is correctly shown, but clicking on the left arrow of the Rad Carousel doesn't seem to be showing the real index of the selected item (doesn't make any sense).

 

Thanks for your attention.

3 Answers, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 28 Jul 2020, 01:59 PM

Hello, George,

Following the provided information I created a test project in order to test this. However, I was not able to observe the described behavior on my end. When I click on the right arrow the indexes increase with changing the images and decrease when clicking on the left arrow, which seems to work properly. You can check the attached gif file. Am I missing something?

Maybe there is something different in your set up. I attached my project for your reference. It would be greatly appreciated if you can modify it in a way to replicate the behavior that you have. Thus, we would be able to investigate the precise case and assist you further.

I am looking forward to your reply.

Regards,
Nadya
Progress Telerik

0
George C.
Top achievements
Rank 2
Iron
Veteran
answered on 29 Jul 2020, 05:56 PM

Yes, your project proves that RadCarousel indexing works just fine. Thanks for your time and apologize me for taking your time.

So, the issue on my end must be related to my coding. After double checking my codes for several times, I figured out that the following code lines are wrongly ordered :

Public current_index As Integer = 0
    Private Sub SlideShow_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SlideShow.SelectedIndexChanged
        Label1.Text = current_index
        current_index = SlideShow.CarouselElement.SelectedIndex
End Sub

 

As you can see, current_index which holds the current index of radcarousel in itself isn't firstly set to the current index and then to be used in label's text. So changing the order of the code lines solves the issue :

Public current_index As Integer = 0
    Private Sub SlideShow_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SlideShow.SelectedIndexChanged
        current_index = SlideShow.CarouselElement.SelectedIndex
        Label1.Text = current_index
 
End Sub

 

Best Wishes,

George C.

 

 

 

 

 

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 30 Jul 2020, 09:50 AM

Hello, George,

I am glad that you managed to found out what causes the problem on your end. Yes, getting the SelectedIndex in a separate variable should happen before assigning it to the Text property of the label in order to provide accurate indexing.

If you need any further assistance I will be glad to help.

Regards,
Nadya
Progress Telerik

Tags
Carousel
Asked by
George C.
Top achievements
Rank 2
Iron
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
George C.
Top achievements
Rank 2
Iron
Veteran
Share this question
or