bpayne111 Posted November 22, 2003 Posted November 22, 2003 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 Quote i'm not lazy i'm just resting before i get tired.
Administrators PlausiblyDamp Posted November 22, 2003 Administrators Posted November 22, 2003 try protected override void OnPaint(PaintEventArgs e) as the declaration Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* mutant Posted November 22, 2003 *Experts* Posted November 22, 2003 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? Quote
bpayne111 Posted November 22, 2003 Author Posted November 22, 2003 thank you all is clear now... Quote i'm not lazy i'm just resting before i get tired.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.