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

another question

Hi,

I know I must be becoming a pain in the ass, but i've encountered yet
another little problem :

I catch an enter keypress with the KeyPress event handler....it does what it
needs to do.....but then after that it still fire the event for the button
that is active at that moment.

I've set e.Handled = true; but it still does that, any way i can resolve
this?

thanks (again :-))

Nov 15 '05 #1
3 1317
dawn,

It should fire the event. The click event is separate from a key press
event. The Handled property is used to indicate if the key press has been
handled. However, pressing the space bar on a button has the effect of
clicking it. If you want to get around this, then for your button, I would
have a module level variable that is set to true when the space bar is
pressed. Then, in the click event handler for your button, check to see if
the flag is true. If it is, do nothing, otherwise, do your processing.

However, this makes me wonder, since the space key and clicking the
button has the same desired effect, why not just handle the click event and
write the code in one place?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dawn" <da******@hotmail.com> wrote in message
news:S_********************@phobos.telenet-ops.be...
Hi,

I know I must be becoming a pain in the ass, but i've encountered yet
another little problem :

I catch an enter keypress with the KeyPress event handler....it does what it needs to do.....but then after that it still fire the event for the button
that is active at that moment.

I've set e.Handled = true; but it still does that, any way i can resolve this?

thanks (again :-))

Nov 15 '05 #2
Well, it doesn't have the desired the desired effect....i press the spacebar
and it does what it needs to do....but then it fires the click event (which
I don't need)....so i'll try it with the flag.

thanks for ur help
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:eW**************@TK2MSFTNGP09.phx.gbl...
dawn,

It should fire the event. The click event is separate from a key press event. The Handled property is used to indicate if the key press has been
handled. However, pressing the space bar on a button has the effect of
clicking it. If you want to get around this, then for your button, I would have a module level variable that is set to true when the space bar is
pressed. Then, in the click event handler for your button, check to see if the flag is true. If it is, do nothing, otherwise, do your processing.

However, this makes me wonder, since the space key and clicking the
button has the same desired effect, why not just handle the click event and write the code in one place?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dawn" <da******@hotmail.com> wrote in message
news:S_********************@phobos.telenet-ops.be...
Hi,

I know I must be becoming a pain in the ass, but i've encountered yet
another little problem :

I catch an enter keypress with the KeyPress event handler....it does what
it
needs to do.....but then after that it still fire the event for the

button that is active at that moment.

I've set e.Handled = true; but it still does that, any way i can

resolve
this?

thanks (again :-))


Nov 15 '05 #3
I think what Nicholas said might be rephrased (forgive me Nicholas if I'm
wrong) this way:

In standard windows forms, pressing the space bar when a button has focus
has the same effect as clicking on the button. Are you absolutely sure you
really want to change this standard behavior for your application? (I'm a
BIG proponent of leaving standard behavior as is, BTW.) If not, then you
can really just write your code in the click event. (But I take it from
your questions that is not the "desired" effect.)

"dawn" <da******@hotmail.com> wrote in message
news:me********************@phobos.telenet-ops.be...
Well, it doesn't have the desired the desired effect....i press the spacebar and it does what it needs to do....but then it fires the click event (which I don't need)....so i'll try it with the flag.

thanks for ur help
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> schreef
in bericht news:eW**************@TK2MSFTNGP09.phx.gbl...
dawn,

It should fire the event. The click event is separate from a key

press
event. The Handled property is used to indicate if the key press has been
handled. However, pressing the space bar on a button has the effect of
clicking it. If you want to get around this, then for your button, I

would
have a module level variable that is set to true when the space bar is
pressed. Then, in the click event handler for your button, check to see

if
the flag is true. If it is, do nothing, otherwise, do your processing.

However, this makes me wonder, since the space key and clicking the
button has the same desired effect, why not just handle the click event

and
write the code in one place?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dawn" <da******@hotmail.com> wrote in message
news:S_********************@phobos.telenet-ops.be...
Hi,

I know I must be becoming a pain in the ass, but i've encountered yet
another little problem :

I catch an enter keypress with the KeyPress event handler....it does

what
it
needs to do.....but then after that it still fire the event for the

button that is active at that moment.

I've set e.Handled = true; but it still does that, any way i can

resolve
this?

thanks (again :-))



Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
3
by: Brad | last post by:
I have another hopefully simple question. I am so used to writing VB .Net windows apps that there are some things in ASP .Net that just does not easily cross over. I know how to pass variables to...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
24
by: David Mathog | last post by:
On a Solaris 8 system if a user "joe" logs in, for instance via ssh, cuserid() returns "joe". That's the expected behavior and so far so good. However if that user then does: % su - sally ...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
4
by: MichaelK | last post by:
Hello. I have all data already collected on the current page? I want to open another window with the form, fill the fields and submit that form. So basically the question is how can I fill all...
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.