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

Determening the front of a carousel

2 Answers 122 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 22 May 2008, 07:13 AM
Im using a Carousel to display some photos.

The behaviour I want is that when I click on front most image (on an ellipse path) I want it displayed in a different frame. However, I cant find any other way of doing this then checking the cursor position of the click (or the position of the object clicked). Are there any other way of determening which is the front most object?

Best regards
Henrik

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 May 2008, 01:51 PM
Hello Henrik,

Thank you for writing.

You should get the foremost object using the radCarousel1.SelectedItem property. You can get the index of the front-most item in the Items collection using the radCarousel1.SelectedIndex property.

You can push an item in the front-most position as shown below:

radCarousel1.SelectedItem = item2;


To achieve your goal please handle the Click event for each item in the Carousel items collection.
When this event is fired, please check the type of the sender. If the sender is a SelectedItem, perform any custom logic you have.

Here is a simple code-block that describes this approach:

             //add items with pictures in carousel
            foreach (Image image in this.radCarousel1.ImageList.Images)
            {

                RadButtonElement carouselItem = new RadButtonElement();
                carouselItem.DisplayStyle = DisplayStyle.Image;
                carouselItem.ShowBorder = false;
          ......
                carouselItem.Image = new Bitmap( image, image.Size.Width/2, image.Size.Height/2);
                carouselItem.Click += new EventHandler(carouselItem_Click);
                this.radCarousel1.Items.Add(carouselItem);
            }
          ......

        void carouselItem_Click(object sender, EventArgs e)
        {
            if( sender == this.radCarousel1.SelectedItem)
            {
                MessageBox.Show("most front");
            }
        }

I hope this helps. If you have any additional questions, please contact me.

All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Henrik
Top achievements
Rank 1
answered on 28 May 2008, 06:23 AM
Great! Thank you!

(For the record; Im very pleased with RadControls!)
Tags
Carousel
Asked by
Henrik
Top achievements
Rank 1
Answers by
Peter
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or