473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1918
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Srinath Avadhanula | last post by:
Hello, I am wondering if QT has something like QWaitForNextEvent() function. This function would block execution of the application till another key was pressed and then return the event...
3
by: Peter S | last post by:
I have function : System::Void Form1_KeyDown(Object* sender, KeyEventArgs* e) but this: this->KeyDown += new KeyEventHandler(this, Form1_KeyDown); doesnt work.. how I can change it to run?...
4
by: Anne | last post by:
hie again, i have 3 textbox and i would like the user to go to the next textbox by pressing the 'ENTER' key. i have tried using this: Private Sub txtRequestor_KeyDown(ByVal sender As...
2
by: Will Gillen | last post by:
I am building a hoem theatre app that is controlled by an IR Remote Control. The Remote has some keys that map to "keyboard" commands (i.e. PageUp, PageDown.). In this VB.NET application I have...
4
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As...
1
by: fripper | last post by:
I have a VB 2005 windows app and I want to recognize keydown events. I have a form key down event handler but it does not get control when a key is depressed. In playing around I found that if I...
0
by: 17beach | last post by:
Control.KeyDown, C#.NET I have a user control with several controls on it. I had the same code in all the controls to call the Winhelp or DO SOME STUFF. The code basically captured the F1 Key...
2
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.