Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a user control which has a pictureBox. When the pictureBox paints i'd like to perform an action.

 

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

i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...