473,779 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
http://www.dotnetmonster.com/Uwe/For...et-vc/200808/1

Aug 13 '08 #1
2 1947
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).
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.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
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
4221
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 which occured. Would like to utlize this in a small application I am building: I am trying to create vi key-bindings for a simple QMultiLineEdit
3
1584
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? please help
4
8637
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 System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtRequestor.KeyDown If e.KeyCode = Keys.Enter Then SendKeys.Send("{TAB}")
2
7260
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 a listbox control that I fill with songs from the MediaPlayer Library (MediaCollection). Now, my remote does not have "Tab" key or "up" and "down" arrow keys, but it does have pageup, pagedown. I want the PageUp, PageDwn to "behave" like the...
4
7130
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 System.Windows.Forms.KeyEventArgs) _ Handles ListBox1.KeyUp, ListBox1.KeyDown If e.KeyValue = Keys.PageDown Or e.KeyValue = Keys.PageUp Or e.KeyValue = Keys.End Or e.KeyValue = Keys.Home Then
1
3310
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 add a keydown event handler for some control on the form, say a textbox ... Private Sub txtBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtBox.KeyDown) and then give that control focus the keydown...
0
2130
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 when the control had the focus. All worked fine, but I had up to 20 controls on a form and the same snippet of code below had to basically be repeated 20 times 1. Create an event for Control in IntitializeComponent() this.MyTextBox.KeydDown += new...
2
19297
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 have created for this purpose is derived from class UserControl.
14
2974
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 reason you would want to do this is for example to trigger something from an OnPaint event without resorting to boolean switches-- say if a user presses the "M" key while the program is Painting, the user gets the PaintHandler to do something else. ...
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.