Reputation:
I'm creating my own user control that can display n amount of images.
Here is the code for it:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebServiceScanner
{
public partial class imageList : UserControl
{
public imageList()
{
InitializeComponent();
}
public List<Image> Images { get; set; }
public void AddImage(Image image)
{
Images.Add(image);
}
public void RemoveImage(Image image)
{
Images.Remove(image);
}
public void MoveImageLeft(int index)
{
Image tmpImage = Images[index];
Images[index] = Images[index - 1];
Images[index - 1] = tmpImage;
}
}
}
I have two questions. Will the .Remove() method, correctly remove the image I want with my current implementation?
Also, I need a way to move an Image to the left by one position. Any suggestions?
Upvotes: 0
Views: 82
Reputation: 15233
"Remove" should work - AFAIK, the CLR will do a hash to compare image objects in the list, and if it sees matching hashes, it will remove the appropriate object.
To move an image left, you could use RemoveAt
and Insert
.
Upvotes: 1