Determening the front of a carousel

3 posts, 0 answers
  1. Henrik
    Henrik avatar
    3 posts
    Member since:
    Apr 2008

    Posted 22 May 2008 Link to this post

    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. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 22 May 2008 Link to this post

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

    Posted 28 May 2008 Link to this post

    Great! Thank you!

    (For the record; Im very pleased with RadControls!)
Back to Top