)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load images in the Carousel?

Platform: WinForms |
Control: Carousel |
Published Date: July 29, 2015 |
Last Revised Date: May 27, 2019

The Carousel control is a circular conveyor where objects are displayed and rotated. The Carousel control provides a 3-D interface for displaying objects with interactive navigation. You can add images through ImageListCollection, that is, only when the ImageSlides property is set to true.

The following code example demonstrates the same.

C#

private void buttonAdv1_Click(object sender, EventArgs e)
{
    for (int i = 1; i <= 5; i++)
    {
        CarouselImage carouselImage = new Syncfusion.Windows.Forms.Tools.CarouselImage();
        // Sets the carousel image.
        carouselImage.ItemImage = Image.FromFile("..\\..\\Images\\" + i + ".jpg");
        //Adds the carousel images to ImageListCollection.
        this.carousel1.ImageListCollection.Add(carouselImage);
    }
    // Displays the images in the Carousel.
    this.carousel1.ImageSlides = true;
}

VB

Private Sub buttonAdv1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonAdv1.Click
    For i As Integer = 1 To 5
        Dim carouselImage As CarouselImage = New Syncfusion.Windows.Forms.Tools.CarouselImage()
        'Sets the carousel image.
        carouselImage.ItemImage = Image.FromFile("..\..\Images\" & i & ".jpg")
        'Adds the carousel images to ImageListCollection.
         Me.carousel1.ImageListCollection.Add(carouselImage)
    Next i
    'Displays the images in the Carousel.
    Me.carousel1.ImageSlides = True
End Sub

 

Note:

The items of the ImageListCollection in the Carousel should contain the Carousel image.

 

 

Images loaded in Carousel

Figure 1: The Carousel images loaded in the Carousel

 

Added new images in Carousel

Figure 2:  The Carousel images added in the Carousel

 

Sample Links:

C#: http://www.syncfusion.com/downloads/support/directtrac/117819/ze/CarouselImage1053207156

VB: http://www.syncfusion.com/downloads/support/directtrac/117819/ze/CarouselImage_VB1305682135

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Larry
Jun 27, 2016
Is there a workaround or how do i add click or mousedown events for the image items from the image list collection? Reply
Larry
Jun 27, 2016
Got it. I used picture boxes.
Kannan R [Syncfusion]
Jun 27, 2016
Hi Larry, We are glad that, your have found solution for this requirement. Please let us know if you need any further assistance. Regards Kannan Reply
Walter Contreras
Jul 27, 2016
Hello How I can do the reverse process? That is, remove the active image from ImageListCollection Reply
Vijayalakshmi Roopkumar [Syncfusion]
Jul 29, 2016
Hi Walter,

Yes, this requirement can be achieved by handling OnCarouselItemSelectionChanging event andusing Remove method in Carousel.

 

Code snippet [C#]

 

void carousel1_OnCarouselItemSelectionChanging(object sender,CarouselItemSelectionChangingArgs e)

{

Carousel carousel = sender as Carousel;

 

List<CarouselImage> imageList = new List<CarouselImage>();

 

foreach (CarouselImage image in carousel.ImageListCollection)

{

 

imageList.Add(image);

 

}

 

foreach(CarouselImage img in imageList)

{

if (img.ItemImage == e.SelectedImage)

{

 

carousel.ImageListCollection.Remove(img);

 

}

 

}

 

 

 


Sample link: 
WindowsFormsApplication195


Video Link:CarouselImage_New


Regards,

Vijayalakshmi V.R.

Walter Contreras
Jul 29, 2016
Thank you. I'll try

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon