473,382 Members | 1,651 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,382 software developers and data experts.

Event handler

16
I'd appreciate it if someone could help me out with this. Currently I am handling instances of the 'enter' key being pressed as:

this.txtBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

this.txtBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

where MM is the name of the form. I want it to work as:

this.txtBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

this.txtBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress2);

but I am not able to do so. When I build the project, "MM_KeyPress2" is automatically reverted to "MM_KeyPress". What is the way out.
Dec 14 '09 #1
8 1610
GaryTexmo
1,501 Expert 1GB
That's weird... I just tried to reproduce this error and was unable to. I created the two event handlers and changed the one for the second text box and it worked just fine.

I wonder if it's intellisense getting you. Are you using Visual Studio? If so, which version?

Maybe when you go to change it, type slowly. If a little box pops up then Visual Studio (or whatever IDE you're using) has intellisense. Though it's strange that it's doing it when you build, not as you type.

Something else you can try... edit the file in notepad and make the change there. Then load up your project and build.... does it still change it?

Last question, does MM_KeyPress2 exist in your class?
Dec 14 '09 #2
Dheeraj Joshi
1,123 Expert 1GB
Even i can't reproduce the error... Its fine for me.....

Yeah, check you have all the event handlers in your code.?

Regards
Dheeraj Joshi
Dec 15 '09 #3
poko
16
I am using Visual Studio 2008. And yes, MM_KeyPress2 exists in the class.

I have defined both MM_KeyPress1 & MM_KeyPress2 in my class. Before building and running the project, the code is:

this.txtBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

this.txtBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress2);

After I build and run the project, and then go back to the code, it automatically changes to:

this.txtBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

this.txtBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);

I can't understand why is this happening. Guess its better to keep only MM_ KeyPress and differentiate between the two by identifying the sender.
Dec 15 '09 #4
Dheeraj Joshi
1,123 Expert 1GB
You told MM_ KeyPress1 and MM_ KeyPress2 are defined then what is MM_ KeyPress in following code of yours.?

Expand|Select|Wrap|Line Numbers
  1. this.txtBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.MM_ KeyPress);
  2.  
Regards
Dheeraj Joshi
Dec 15 '09 #5
poko
16
I never said that MM_ KeyPress1 is defined.

Only MM_ KeyPress & MM_ KeyPress2
Dec 15 '09 #6
Dheeraj Joshi
1,123 Expert 1GB
I have defined both MM_KeyPress1 & MM_KeyPress2 in my class. Before building and running the project, the code is:
I am afraid,Just in the previous post you said that.

Regards
Dheeraj Joshi
Dec 15 '09 #7
GaryTexmo
1,501 Expert 1GB
Try changing it outside of Visual Studio and then loading up the project. Does it change it back then?

If it does, try compiling with just the command line tools, it shouldn't make any code changes with that.

This is a very strange issue...
Dec 15 '09 #8
poko
16
@ Dheeraj. Sorry, my mistake. Basically it can be MM_ KeyPress & MM_ KeyPress2 or MM_ KeyPress1 & MM_ KeyPress2. My point was that I am unable to keep both of them in the code.

@Gary. Yes, compiling at command line did help. Thanks a lot for the tip.
Dec 15 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
6
by: vbMark | last post by:
If I have a control, for example a CheckedListBox, how do I add and event to code, for example that a box has been checked by the user? Thanks
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
3
by: Beth | last post by:
in the following: this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click); if I saw an equation, such as y +=x; then y = y+x. But what is the meaning in the event handler. I...
5
by: Richard Grant | last post by:
Hi, I need to "save" in a variable the event handler sub of a control's event, then perform some process, and finally "restore" the originally saved event handler. Example in pseudo-code: 1)...
1
by: tdan | last post by:
I do not know how to get Event.stopObserving() to work in the context I am using it. I am displaying a Color Selection Table and attaching 2 events: 1. onmouseover to display the color to the user...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
2
by: =?Utf-8?B?UlJK?= | last post by:
Hello, I would like to add the Paint handler to the form. How to do it? Thanks in advance.
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.