C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Info: The ImageList is simple to create. We add images manually or dynamically.
Next: Try right-clicking on the ImageList instance and select Properties. From there, you can add images manually in the dialog.
Instance: Please select the ImageList instance you created as the value of these properties.
Then: You can use the ListView to specify the index of the images inside your ImageList.
ListViewHere: We have a list of file names, and then add each as an Image object using the Image.FromFile method to read the data.
Info: The Form1_Load event handler is used to make sure the code is run at startup of the application.
Example of using Add method on ImageList: C#
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Add these file names to the ImageList on load.
string[] files = { "image.png", "logo.jpg" };
var images = imageList1.Images;
foreach (string file in files)
{
// Use Image.FromFile to load the file.
images.Add(Image.FromFile(file));
}
}
}
}
Finally: You can add images manually through Visual Studio or dynamically through C# code using the ImageList.