Child Control Events in User Control C#

bpayne111

Junior Contributor
Joined
Feb 28, 2003
Messages
325
Location
BFE
I have a user control which has a pictureBox. When the pictureBox paints i'd like to perform an action.

C#:
public class UserControl1

//auto generated code

{
//picLogo created in designer
private override void picLogo_OnPaint (System.Windows.Forms.PaintEventArgs e)
		{
			
			MessageBox.Show("painted");

		}
}

with this code i get an error saying "Virtual or abstract methods cannot be private" I changed it to public and then get an error saying "There is no matching method to override."
What do i have to do to make that work?

brandon
 
The error says it all "There is no matching method to override" :)
You are putting that override in your UserControl1 class, so what the code attempts to do is to override a method called picLogo_OnPaint, which does not exist in the UserControl class from which you inherit (at least I think you inherit from that because the code doesn't show). Even when you change it to OnPaint, it wont work as you want it to, it will work but you will get the override for the paint event on your user control now, not the picturebox. Why not simply use the Paint event?
 
Back
Top