473,785 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect if "down" or "up" key is pressed?

7 New Member
I am having trouble detecting if "down" or "up" key is pressed within a textbox.

Evidently those keys do not fire the "KeyPressed " event.

Does anyone know how to detect when they are pressed?
Dec 18 '09 #1
5 4580
GaryTexmo
1,501 Recognized Expert Top Contributor
Try the KeyDown event instead, it will get arrow key presses :)
Dec 18 '09 #2
tlhintoq
3,525 Recognized Expert Specialist
Check the args against the Keys.Down or Keys.Up
Dec 18 '09 #3
JamesX
7 New Member
Thanks, it worked great. But now I encountered another problem.

It seems that the Up and Down Key moves the selectIndex.

I adjusted it by simply adding or subtracting by 1. It doesn't work when the selection index is at the beginning and the end of the string since it seems to be increment/decrement after the event fired.

It won't let me increment pass the length of the string so if I press Up at the end of the string, it will always move the selectionIndex back 1.

Is there a way to disable moving the caret on up and down? or I have to use a round-bout method??
Dec 18 '09 #4
tlhintoq
3,525 Recognized Expert Specialist
You should be able to intercept the message before it makes the move to begin with.

In your KeyDown handle method, it will have received a KeyPressArgs or something similar being assigned to variable e

You can then set e.Handled = true
So the OS doesn't pass the event any further, since you have handled it.
Dec 18 '09 #5
JamesX
7 New Member
Thank you very much for the help :)
Sorry about being a total newbie at programming.
Much appreciated :)
Dec 18 '09 #6

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

Similar topics

0
1381
by: djefanten | last post by:
Hi, I have a windows form with a combobox on it (it has the DropDown as DropDownStyle, which means you can type free text in it OR you can select from a list). At the moment that combobox receives focus, I need to display a small form on the side of the dropped down combobox with a keyboard simulated on it. Ok, I managed to get another form floating on the side, using a good article on vbaccelerator.com, I can get the input from the...
17
1662
by: in | last post by:
You know, why does Microsoft even bother to spend money to thwart Linux when it's top supporters act like such buffoons anyway...?! http://www.eweek.com/article2/0,1759,1772633,00.asp#talkback New OSI President Steps Down By Steven J. Vaughan-Nichols March 4, 2005
18
8087
by: Leslaw Bieniasz | last post by:
Cracow, 28.10.2004 Hello, I have a program that intensively allocates and deletes lots of relatively small objects, using "new" operator. The objects themselves are composed of smaller objects, again allocated using "new". From my tests I deduce that a considerable part of the computational time is spent on the memory allocation, which makes the program substantially slower compared to the equivalent code written using
17
2007
by: Will Hartung | last post by:
I have a table for a report. It can get wide, but that's no big deal. I don't mind that it can get wide. What I do mind, though, is the browser doing its damndest to smash the thing down to get it to fit the window (to no avail). It crams it down until it can't cram any more and then pops up the horizaontal scroll bar, rather than just "let go", and set the table free, scrollbar be damned. Is there a way to tell the browser that my...
72
4236
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and c?
28
3006
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. Ruby has ... an issue with docs. That is to say, there are almost none. Well, actually, there are some. For example, the "PickAxe" book (google it), and "Why's" Poignant Guide. But there's a disturbing lack of *built-in* docs for Ruby. Now, the...
0
1729
by: U S Contractors Offering Service A Non-profit | last post by:
ALOT of them to pick from... Inbox Reply Craig Somerford to uscosoct24, Matthew, B-eing-I-nstru., Ed, me, New, mw, Natural, (bcc:USA), (bcc:Letters), (bcc:lvargas), (bcc:Le), (bcc:staff), (bcc:Local) show details 2:57 am (0 minutes ago) " A match made in Heaven "
10
3599
by: JHNielson | last post by:
I am designing an interface, and I would like to customize the buttons instead of using the plain gray boxes that are standard in Access. Is there a way to set for the "On Mouse Up" and "On Mouse Down" events for the control to display two different pictures? I have two pictures: Button-UP.jpg and Button-Down.jpg. Can is set Access to show Button-Down on the "on mouse down event" and show the Button-UP on the "on mouse up" events? ...
0
2215
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL Server 2000 We are having some problems with a website we are developing, and had some
0
9643
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
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
10147
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
10083
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
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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

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.