|
-
July 25th, 2007, 10:31 PM
#1
using foreach and arraylist
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|