It's really simple - please refer to one of my previous answers to the same kind of question:
How to read a barcode using a barcode scanner[
^]
In addition to the linked answer: Most barcode scanners automatically append a return character to the scanned barcode by default, otherwise it can be configured that way (or to append a different or no character).
Edit after comment:
If you have your barcode scanner configured to append a return character then you can use this kind of code to process a scanned barcode:
public Form1()
{
InitializeComponent();
BarcodeTextBox.KeyDown += BarcodeTextBoxKeyDown;
}
private void BarcodeTextBoxKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
string barcode = BarcodeTextBox.Text;
BarcodeTextBox.Text = "";
e.Handled = true;
}
}