How to read barcode scanner and recieve it on datagridview pos phramacy ?

ahmed salah 3,216 Reputation points
2021-09-11T18:41:20.167+00:00

I work on c# windows desktop application on POS Form for pharmacy

I need to read barcode to datagridview for every item

AND when read another item again go to next line

for every reading barcode

so are there are any sample for pos form with datagridview

on GitHub or any web site

so i can't receive and read barcode on datagridview ?

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    e.SuppressKeyPress = true;
    int iColumn = dataGridView1.CurrentCell.ColumnIndex;
    int iRow = dataGridView1.CurrentCell.RowIndex;
    if (iColumn == dataGridView1.Columncount-1)
    {
        if (dataGridView1.RowCount > (iRow + 1))
        {
            dataGridView1.CurrentCell = dataGridView1[1, iRow + 1];
        }
        else
        {
            //focus next control
        }
    }
    else
        dataGridView1.CurrentCell = dataGridView1[iColumn + 1, iRow];
}
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,841 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,316 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Adam Jachocki 46 Reputation points
    2021-09-15T09:47:32.163+00:00

    Barcodes can work in two modes

    • COM port
    • Keyboard

    Different barcodes can work in either of these modes or in both of them. You should check yours.
    If your reader works in COM port mode, then just read from this port. When you get the data, just create new item, add read number and add the item to datagrid.

    If your reader works in keyboard mode it is much more complicated. The simplest option would be to keep focus on some TextBox and on ENTER add the content of the textbox to new row in datagrid.

    Notice that readers that work in keyboard mode should give you ENTER at the end of the number read, for example:

    "123456\n" or "123456\r\n"

    0 comments No comments