Hello all,
To help alleviate human error, I'm developing an application that uses a
barcode reader to fill in a value in a TextBox control. The barcode
reader is connected to the PC through the PS2 keyboard jack, so to
Windows, it's essentially just a keyboard. After the reader has
finished reading the barcode, it sends out Ctrl + M (which I *think* is
a carriage return).
To capture the Ctrl + M, I configured an event handler for the
PreviewKeyDown event. In the event handler, I have tried the following:
private void MyTextBox_Previ ewKeyDown(objec t sender,
PreviewKeyDownE ventArgs e)
{
// First way I tried
if (e.Control && e.KeyCode == Keys.M)
{
ShowNewDialog() ;
}
// Second way I tried
if ((int) e.KeyData == (int) (Keys.M | Keys.Control))
{
ShowNewDialog() ;
}
}
Essentially, both of them do the same thing, but the first one is less
confusing to somebody that reads my code later.
At any rate, the code works --kind of. The problem is that after
ShowNewDialog() returns, the letter "m" shows up in the MyTextBox
control. If I comment out the call to ShowNewDialog() , the letter "m"
never shows up.
Short of an ugly "fix", such as removing the letter "m" after
ShowNewDialog() returns, I'm not sure what else to do. I was hoping
there was a better way of capturing the carriage return that I haven't
thought of.
Any suggestions?
Thank you in advance,
--
Sean 2 4243
Hi,
Any reason for using PreviewKeyDown instead of KeyDown?
If you are using KeyDown you can use the KeyEventArgs.Ha ndled = true to
suppress keys
On Fri, 03 Nov 2006 15:45:52 +0100, senfo
<en**********@y ahoo.comI-WANT-NO-SPAMwrote:
Hello all,
To help alleviate human error, I'm developing an application that usesa
barcode reader to fill in a value in a TextBox control. The barcode
reader is connected to the PC through the PS2 keyboard jack, so to
Windows, it's essentially just a keyboard. After the reader has
finished reading the barcode, it sends out Ctrl + M (which I *think* is
a carriage return).
To capture the Ctrl + M, I configured an event handler for the
PreviewKeyDown event. In the event handler, I have tried the following:
private void MyTextBox_Previ ewKeyDown(objec t sender,
PreviewKeyDownE ventArgs e)
{
// First way I tried
if (e.Control && e.KeyCode == Keys.M)
{
ShowNewDialog() ;
}
// Second way I tried
if ((int) e.KeyData == (int) (Keys.M | Keys.Control))
{
ShowNewDialog() ;
}
}
Essentially, both of them do the same thing, but the first one is less
confusing to somebody that reads my code later.
At any rate, the code works --kind of. The problem is that after
ShowNewDialog() returns, the letter "m" shows up in the MyTextBox
control. If I comment out the call to ShowNewDialog() , the letter "m"
never shows up.
Short of an ugly "fix", such as removing the letter "m" after
ShowNewDialog() returns, I'm not sure what else to do. I was hoping
there was a better way of capturing the carriage return that I haven't
thought of.
Any suggestions?
Thank you in advance,
--
Happy Coding!
Morten Wennevik [C# MVP]
Morten Wennevik wrote:
Any reason for using PreviewKeyDown instead of KeyDown?
If you are using KeyDown you can use the KeyEventArgs.Ha ndled = true to
suppress keys
Hi Morten,
That's a good question and I don't have an answer for you. Using the
KeyDown event fixed everything.
Thank you very much!
--
Sean This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Canes_Rock |
last post by:
The information posted at:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=slrnarv28n.e4j.TuxTrax%40fortress.tuxnet&rnum=1&prev=/groups%3Fq%3Dsuppress%2Bcarriage%2Breturn%2Bgroup:comp.lang.python.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.lang.python.*%26selm%3Dslrnarv28n.e4j.TuxTrax%2540fortress.tuxnet%26rnum%3D1
seemed to provide a solution to eliminating the line feed and causing
a carriage return for the text displayed...
|
by: Les Juby |
last post by:
Can someone please help with a suggestion as to how I can keep the
formatting (carriage returns) that the user enters into a memo field
and then display that later.
I figured I might be able to use:
'replace carriage returns with BRs
comment=Replace(comment, chr(13), "<br>")
but obviously net.!
The <pre> tag doesn't sem to help either as the embedded return is
|
by: Josh |
last post by:
Hi,
I'm using System.Data.DataSet.ReadXml to convert some xml from a webservice
to a DataSet. The xml looks like:
<?xml version="1.0"
encoding="UTF-8"?><root><prioritiesTable><description>blah blah
blah
blah</description></prioritiesTable></root>
The important thing here is the
which I beleive should be a single
|
by: Andrew Chanter |
last post by:
I have a VBA function that returns a string including "vbcr" (VB Carriage
Return) to seperate a list into multiple rows, eg Item1 & vbcr & Item2 &
vbcr & Item3
This works as planned in the immediate window, producing a list where a
Carriage Return follows each item. But when I output the result into either
an Access query or form, instead of carriage returns I get little square
symbols between each of the items. Is anyone able to tell...
|
by: eagleofjade |
last post by:
I am trying to import data from a Word document into an Access table
with VBA.
The Word document is a form which has various fields. One of the fields
is a field for notes. In some cases, this note field contains carriage
returns.
When I import a note field that has carriage returns, what shows up in
the Access field are vertical black lines where the carriage return
should be.
| |
by: Matt Mercer |
last post by:
Hi all,
I am having a frustration problem, and I have read about 25 newsgroup
postings that do not have a satisfying answer :)
The problem appears to be common where carriage returns are lost when
pulling data from an SQL database. The thing that frustrates me the
most, is that when I use Enterprise Manager, the carriage returns ARE
THERE. It looks fine until I pull it out.
|
by: Dinsdale |
last post by:
I have an xml file that is read into an object using serialization. One
of the objects has a string field called delimeter that I want to
contain a carriage return. Instead of trying to include the carriage
return, I used "\r" thinking that when it was read back into the object
it would be interpreted as a carriage return. Instead, I am getting the
string literal instead of the escape sequence. Does anybody have a
slick way of telling it...
|
by: shajias |
last post by:
Hi,
I am having a xml code like this
<name>
I am having a carriage return here.
Second line with carriage return.
This is the last line.
</name>
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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();...
|
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...
|
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: 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...
| |