Remove carriage return from barcode scan into textbox column in dataGridView

Posted on 2009-12-22
Last Modified: 2013-11-10
The user is using a barcode scanner that has a carriage return, to scan a barcode into a dataGridView textbox column.  I need to remove that carriage return so the focus stays in the current cell after the scan.  I know I can do a string.replace to remove the "\r\n"  but I cannot catch it in the correct event. Any ideas?

Key down, key press and key up events do not work as it is too the the carriage return already executed and the focus is in the new row.  I was thinking CellBeginEdit or CellValidating but don't know how I could strip off the carriage return in those events?
Question by:MBND
    LVL 8

    Expert Comment

    by:deepu chandran

    Author Comment

    The link shows how to do a string.replace which I know how to do....the problem is what event can this be done in for my situation described above.  

    LVL 3

    Accepted Solution

    Configure the scanner to remove the post-amables from the scan.  You will see this in the programming guide for the barcode scanner and usually involves scanning a few programming barcodes.  This is the most straight forward method as it envolves no software changes.


    Author Comment

    I ended up focusing in the dataGridViewCell that i wanted to be in after the carriage return.  This has solved my problem for now.  

    Phil - thanks for the suggestion but in this case, in this app the carriage return is needed in all other instances.  

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now