469,578 Members | 1,775 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

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. InitializeComponent() is being called from Constructor of the
Form Class.

void InitializeComponent(void)
{
this->txtRONumber = (gcnew System::Windows::Forms::TextBox());

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

private: System::Void txtRONumber_KeyDown(System::Object^ 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 InitializeComponent() function. I mean this line:

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

Any idea/suggestion?

ThanX.
Sush

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...et-vc/200808/1

Aug 13 '08 #1
2 1733
On Aug 13, 10:16*pm, "sush_jd via DotNetMonster.com" <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. InitializeComponent() is being called from Constructor of the
Form Class.

void InitializeComponent(void)
{
* * * * this->txtRONumber = (gcnew System::Windows::Forms::TextBox());

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

}

private: System::Void txtRONumber_KeyDown(System::Object^ *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 InitializeComponent() function. I mean this line:

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

Any idea/suggestion?
Well, yes. Assuming you use the WinForms visual designer,
InitializeComponents() 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 InitializeComponents() (and possibly refactor it into your own
separate method).
Aug 14 '08 #2
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.com" 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. InitializeComponent() is being called from Constructor of the
Form Class.

void InitializeComponent(void)
{
this->txtRONumber = (gcnew System::Windows::Forms::TextBox());

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

private: System::Void txtRONumber_KeyDown(System::Object^ 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 InitializeComponent() function. I mean this line:

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

Any idea/suggestion?

ThanX.
Sush

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...et-vc/200808/1

Aug 14 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Srinath Avadhanula | last post: by
3 posts views Thread by Peter S | last post: by
4 posts views Thread by Anne | last post: by
2 posts views Thread by Will Gillen | last post: by
4 posts views Thread by ShaneO | last post: by
1 post views Thread by fripper | last post: by
reply views Thread by 17beach | last post: by
2 posts views Thread by Tony Johansson | last post: by
14 posts views Thread by raylopez99 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.