Category / Section
How to load images in the Carousel?
1 min read
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.
Figure 1: The Carousel images loaded in the 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