Barcode Scanner Selling GoodsExample DescriptionNowadays, many supermarkets use bar codes to sell goods. The computer operator uses the scanner to scan the barcode of the product, and the details of the product are displayed on the screen. This example realizes the use of bar code to sell goods function. The effect is shown in Figure 13.19.Technical PointsWhen you scan a barcode with a scanner, the barcode data is displayed in the window control that currently has the focus. For example, if the current edit box has the focus, the barcode data is displayed in the TextBox text box. It then sends a message to the TextBox text box when the ENTER key is pressed. In the program, just trigger the KeyDown event of the TextBox text box to determine if the current key is the enter, and if so, read the barcode data in the TextBox text box, and query the product information from the datasheet according to the barcode to display it in the DataGridView list.implementation Process (1) Create a new item, named Ex13_18, and the default form is Form1. (2) in the Form1 form, a TextBox control is mainly added to receive barcodes, and a DataGridView control is added to display the product sales information that the scanner scans for barcodes. (3) Main program code. private void Textbox1_keydown (object sender, KeyEventArgs e) & nbsp; { if (E.keyvalue = = { OleDbConnection con = new OleDbConnection ("provider= Microsoft.jet.oledb.4.0;data source= "+" Price.mdb "+"; Persist security Info=false "); OleDbDataAdapter dap = New OleDbDataAdapter ("SELECT * from Merchandiseinfo where barcode= '" + TextBox1.Text + "", con); DataSet ds = new DataSet (); DAP. Fill (DS); if (ds. Tables[0]. Rows.Count = 0) { MessageBox.Show ("This product does not exist.") "," System hint ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < Datagridview1.rowcount ; i++) { if (Convert.ToString ( Datagridview1[0, I]. Value) = = "") { datagridview1[0, I]. Value = ds. Tables[0]. Rows[0][0]. ToString (); datagridview1[1, I]. Value = ds. Tables[0]. ROWS[0][1]. ToString (); datagridview1[2, I]. Value = ds. Tables[0]. ROWS[0][2]. ToString (); Datagridview1[3, I]. Value = ds. Tables[0]. ROWS[0][3]. ToString (); return; } } } }