KeyDown Event Handler Generator Code Disappears

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sush_jd via DotNetMonster.com

    KeyDown Event Handler Generator Code Disappears

    I am using managed VC++ code in a Win Form App. There is a text box -
    txtRONumber. I have defined a KeyDown event handler (non-default) for it,
    like below. InitializeCompo nent() is being called from Constructor of the
    Form Class.

    void InitializeCompo nent(void)
    {
    this->txtRONumber = (gcnew System::Windows ::Forms::TextBo x());

    this->txtRONumber->Location = System::Drawing ::Point(151, 35);
    this->txtRONumber->Name = L"txtRONumbe r";
    this->txtRONumber->Size = System::Drawing ::Size(124, 22);
    this->txtRONumber->TabIndex = 0;
    this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
    txtRONumber_Key Down);
    }

    private: System::Void txtRONumber_Key Down(System::Ob ject^ sender,
    KeyEventArgs^ e);


    Now, I am not sure but either when I add another control to the Form and
    rebuild my app or add control, rebuild, close solution, reopen and rebuild,
    sometime during any of these the event handler generator gets disappeared
    from the InitializeCompo nent() function. I mean this line:

    this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
    txtRONumber_Key Down);

    Any idea/suggestion?

    ThanX.
    Sush

    --
    Message posted via DotNetMonster.c om
    Best online pokies for real money in Australia and learn about safety and game mechanics in this comprehensive guide.


  • Pavel Minaev

    #2
    Re: KeyDown Event Handler Generator Code Disappears

    On Aug 13, 10:16 pm, "sush_jd via DotNetMonster.c om" <u45310@uwe>
    wrote:
    I am using managed VC++ code in a Win Form App. There is a text box -
    txtRONumber. I have defined a KeyDown event handler (non-default) for it,
    like below. InitializeCompo nent() is being called from Constructor of the
    Form Class.
    >
    void InitializeCompo nent(void)
    {
            this->txtRONumber = (gcnew System::Windows ::Forms::TextBo x());
    >
            this->txtRONumber->Location = System::Drawing ::Point(151, 35);
            this->txtRONumber->Name = L"txtRONumbe r";
            this->txtRONumber->Size = System::Drawing ::Size(124, 22);
            this->txtRONumber->TabIndex = 0;
            this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
    txtRONumber_Key Down);
    >
    }
    >
    private: System::Void txtRONumber_Key Down(System::Ob ject^  sender,
    KeyEventArgs^  e);
    >
    Now, I am not sure but either when I add another control to the Form and
    rebuild my app or add control, rebuild, close solution, reopen and rebuild,
    sometime during any of these the event handler generator gets disappeared
    from the InitializeCompo nent() function. I mean this line:
    >
    this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
    txtRONumber_Key Down);
    >
    Any idea/suggestion?
    Well, yes. Assuming you use the WinForms visual designer,
    InitializeCompo nents() method is for generated code - adding your own
    code to it is just asking for trouble. If you want to do your own
    custom code-based initialization, do it in the constructor after the
    call to InitializeCompo nents() (and possibly refactor it into your own
    separate method).

    Comment

    • =?Utf-8?B?U3RldmUgQmVobWFu?=

      #3
      RE: KeyDown Event Handler Generator Code Disappears

      Are you trying to simulate a "masked textbox" with a "regular textbox" to
      avoid the ugliness of masks? I have (with Pavel's help) written code to
      accomplish that end.

      If that is your goal, I will be glad to share the procedure and code to
      implement this, just post a message to this thread. Otherwise ignore this
      post!

      BTW: Pavel is one truly helpful guy.

      "sush_jd via DotNetMonster.c om" wrote:
      I am using managed VC++ code in a Win Form App. There is a text box -
      txtRONumber. I have defined a KeyDown event handler (non-default) for it,
      like below. InitializeCompo nent() is being called from Constructor of the
      Form Class.
      >
      void InitializeCompo nent(void)
      {
      this->txtRONumber = (gcnew System::Windows ::Forms::TextBo x());
      >
      this->txtRONumber->Location = System::Drawing ::Point(151, 35);
      this->txtRONumber->Name = L"txtRONumbe r";
      this->txtRONumber->Size = System::Drawing ::Size(124, 22);
      this->txtRONumber->TabIndex = 0;
      this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
      txtRONumber_Key Down);
      }
      >
      private: System::Void txtRONumber_Key Down(System::Ob ject^ sender,
      KeyEventArgs^ e);
      >
      >
      Now, I am not sure but either when I add another control to the Form and
      rebuild my app or add control, rebuild, close solution, reopen and rebuild,
      sometime during any of the event handler generator gets disappeared
      from the InitializeCompo nent() function. I mean this line:
      >
      this->txtRONumber->KeyDown += gcnew KeyEventHandler (this, &FrmRepairOrder ::
      txtRONumber_Key Down);
      >
      Any idea/suggestion?
      >
      ThanX.
      Sush
      >
      --
      Message posted via DotNetMonster.c om
      Best online pokies for real money in Australia and learn about safety and game mechanics in this comprehensive guide.

      >
      >

      Comment

      Working...