hi, i have a arraylist which contains a list of objects to be drawn using DrawRectangle,DrawPolygon, etc. I want to use COntains method in 'foreach' to check whether the mouseclick position is within the
rectangle of the shape. Below is my code:
<code>
private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
int i=0;
Point p=new Point(e.X,e.Y);
foreach(ArrayList d in alDrawingObjects)
{
if(alDrawingObjects.Contains(p))
{
isCanvasShape=true;
ShapeNo=d.IndexOf(alDrawingObjects);
}

}
}
</code>

The error generated is "An unhandled exception of type 'System.InvalidCastException' occurred in DrawShape.exe

Additional information: Specified cast is not valid."

Anybody can help to explain what i should modify?

Thanks in advance