question

ahmedsalah-1628 avatar image
0 Votes"
ahmedsalah-1628 asked AdamJachocki-5815 answered

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

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];
 }
dotnet-csharpwindows-forms
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

For anyone to assist you need to make more of an effort than what is shown.

0 Votes 0 ·

1 Answer

AdamJachocki-5815 avatar image
0 Votes"
AdamJachocki-5815 answered

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"



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.