Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4560714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:58:14+00:00 2026-05-21T17:58:14+00:00

So, I am creating a Windows Forms Application in Visual C++ 2010, and I

  • 0

So, I am creating a Windows Forms Application in Visual C++ 2010, and I want to add an event to a text box. When the program loads, a letter A is printed onto the screen. When you enter the text box, the letter is supposed to turn red.

The name of the textbox is AngleA, and this is the code I have so far:

this->AngleA->Enter += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::AngleA_Enter);
//many lines later
this->Controls->Add(this->AngleA);
//many lines later
public: System::Void Form1::AngleA_Enter(System::Object^  sender, PaintEventArgs^  e) 
     {
         System::Drawing::Font^ textFontA = gcnew System::Drawing::Font("Arial", 16);
         System::Drawing::SolidBrush^ textBrushA = gcnew System::Drawing::SolidBrush(Color::Red);
         e->Graphics->DrawString("A", textFontA, textBrushA, 300, 120);
     }

The original drawing of the letter happens in a separate function, here:

    public: virtual Void Form1::OnPaint(PaintEventArgs^ pe ) override
{
   Graphics^ g = pe->Graphics;

   System::Drawing::Font^ textFont = gcnew System::Drawing::Font("Times New Roman", 16);

   SolidBrush^ textBrushA = gcnew SolidBrush(Color::Black);

   g->DrawString("A", textFont, textBrushA, 300, 120);

}

So, the drawing of the original letter works great, but every time I try to build the program with the Enter event, I get the following error:

error C2664: 'System::Windows::Forms::Control::Enter::add' : cannot convert parameter 1 from 'System::Windows::Forms::PaintEventHandler ^' to 'System::EventHandler ^'
1>          No user-defined-conversion operator available, or
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

It seems to me that the form1 object (default name for class in windows forms apps) will only accept an EventHandler parameter for the “this->AngleA->Enter += gcnew ” and not PaintEventHandler, but I dont understand why. Is there any way to create an Enter event function that will allow me to paint after the program has already loaded, based on an event?

Thanks for the help, I hope I was clear in my question 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:58:15+00:00Added an answer on May 21, 2026 at 5:58 pm

    You can only add a PaintEventHandler to the Paint event; not to the Enter event.

    You probably want to add a normal EventHandler to the Enter event and call Invalidate() in the handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Windows Forms application and I'd like to have a similar look
I am creating a Windows forms application and my SQL Server database is on
I am creating my first Windows Forms application, to be deployed on Windows Mobile
When I create a 'Windows Forms Application', the resultant program is a managed one.
We are creating a Windows Form application (C# or VB.NET) that needs to reference
I am creating a Windows Forms control derived from UserControl to be embedded in
I am creating windows installer project using Visual Studio 2005. Is there an option
Is there a free software for creating windows help files for your program? I
I am creating a windows service and want to know best practices for this.
I am creating a C# windows application to create an Excel 2003 sheet. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.