I have two controls for displaying images from a folder, they are: ImageList
and ListView
Now I can to display images using the above controls simply without any criteria.
- But I want to:
Show Images based on the date of image created. For this purpose I have one DateTimePicker
control to select the date , one ComboBox
to select an Option and one Button
to show the result as shown in the following snapshot.
For Example: Show image before the date 15/1/2015, date from the image tag.
This is the code which I used to display the image in to the ListView
private void btn_Show_Click(object sender, EventArgs e)
{
lstView_un.Items.Clear();
DirectoryInfo dir = new DirectoryInfo(@"D:\Images");
foreach (FileInfo file in dir.GetFiles())
{
try
{
this.imageList1.Images.Add(Image.FromFile(file.FullName));
}
catch
{
Console.WriteLine("This is not an image");
}
}
this.imageList1.ImageSize = new Size(256, 250);
this.lstView_un.LargeImageList = this.imageList1;
for (int j = 0; j < this.imageList1.Images.Count; j++)
{
ListViewItem item = new ListViewItem();
item.ImageIndex = j;
this.lstView_un.Items.Add(item);
}
}