Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Single Textbox EventHandler for all

Single Textbox EventHandler for all

Scheduled Pinned Locked Moved Managed C++/CLI
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Badboy22TR
    wrote on last edited by
    #1

    Hi, i have lots of textbox on my form, instead of adding several eventhandlers for textchanged or keypressed, i wrote a single one for all. It worked then i decided to move it to another class, but i can't bind it to eventhandler. I don't know what i did wrong. Can anyone help me please? //If i put the code on form's class it works this->textBox7->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &AA::SM_KeyPress); private: System::Void SM_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) { ...} //But when i try to do this, i got several errors //1>error C2276: '&' : illegal operation on bound member function expression //1>error C3350: 'System::Windows::Forms::KeyPressEventHandler' : a delegate constructor expects 2 argument(s) this->textBox9->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &AA::G1->SM_KeyPress); G1 is an another class, i added these lines to use library. #include "Genel.h" using namespace Util; private : Util::Genel^ G1; Thank you very much...

    K 1 Reply Last reply
    0
    • B Badboy22TR

      Hi, i have lots of textbox on my form, instead of adding several eventhandlers for textchanged or keypressed, i wrote a single one for all. It worked then i decided to move it to another class, but i can't bind it to eventhandler. I don't know what i did wrong. Can anyone help me please? //If i put the code on form's class it works this->textBox7->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &AA::SM_KeyPress); private: System::Void SM_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) { ...} //But when i try to do this, i got several errors //1>error C2276: '&' : illegal operation on bound member function expression //1>error C3350: 'System::Windows::Forms::KeyPressEventHandler' : a delegate constructor expects 2 argument(s) this->textBox9->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &AA::G1->SM_KeyPress); G1 is an another class, i added these lines to use library. #include "Genel.h" using namespace Util; private : Util::Genel^ G1; Thank you very much...

      K Offline
      K Offline
      ky_rerun
      wrote on last edited by
      #2

      I recreated your situation Make sure you crete an instace that points to the class thats going to handle the event in this case HA HandleAccessor^ HA; this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(HA, &HandleAccessor::textBox2_KeyPress);


      a programmer traped in a thugs body

      B 1 Reply Last reply
      0
      • K ky_rerun

        I recreated your situation Make sure you crete an instace that points to the class thats going to handle the event in this case HA HandleAccessor^ HA; this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(HA, &HandleAccessor::textBox2_KeyPress);


        a programmer traped in a thugs body

        B Offline
        B Offline
        Badboy22TR
        wrote on last edited by
        #3

        It works!!! :) Thank you very much...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups