I try to get the Heu value from where i click on an image, however I am doing something wrong and i am not sure what it is, it has to do with the designer file and how i call the function _mousedown of the image.
in my main.designer.cs file i have:
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(146, 30);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(640, 480);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//line below is not accepted ??
this.pictureBox1.MouseDown += new System.EventHandler(this.pictureBox1_MouseDown);
in my main program i have :
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point Cursor = new System.Drawing.Point(e.X, e.Y);
Color pixel = myImage.GetPixel(Cursor.X, Cursor.Y);
textBoxH.Text =pixel.GetHue().ToString();
}
The error i get is :
*’System.Windows.Forms.PictureBox’ does not contain a definition for ‘pictureBox1_MouseDown’ and no extension method ‘pictureBox1_MouseDown’ accepting a first argument of type ‘System.Windows.Forms.PictureBox’ could be found
are you missing a using directive or an assembly reference?)
C:\projects\visual studio 2010\Projects\image\Main.Designer.cs**
Note i have included using System; above in my main program.
*UPDATE *
After compile i now get a different error (have not changed the code)
Error 1 No overload for ‘pictureBox1_MouseDown’ matches delegate ‘System.EventHandler’
Looks to my like you hand coded a change to your designer file. If you did, stop doing that: designer generated code should not be touched as VS will screw with it.
Regardless, that’s not the right definition for a mouse down event.
The following:
should be: