In addition to the problem pointed out by Mika:
Your question is no more that the indication of the fact you are not using debugger, it looks like. If you want to develop anything seriously, you need to have elementary skills of using the debugger whenever you have a problem, and at lease before asking a question like that. Also, do you understand that methods like
pictureBox1_MouseUp
are not events? Only the name suggests that the purpose of the method was related to using them as event handlers. Besides, such names violate (good) Microsoft naming conventions. Yes, they are generated by Microsoft Designer, so what? Who told you you are supposed to keep them? You need to renamed everything to some semantic names. Even better, avoid names at all. All you need is anonymous methods:
this.pictureBox1.MouseMove += (sender, eventArgs) => { }
this.pictureBox1.MouseUp += delegate(object sender, MouseEventArgs eventArgs) { }
Now, more important problem:
The whole idea of using the class
PictureBox
for any interactive behavior you are trying to achieve is completely pointless. Even though this is possible, the
PictureBox
functionality does not add anything useful, but only creates unwanted hassles and eats up resources and extra development time. Instead, you need to use a custom control based on
System.Windows.Forms.Control
.
I explain this and what to do in my past solution:
How do I clear a panel from old drawing[
^].
—SA