Hi Guys,
Before doing the C# code we have to design out mobile windows application as per given below.
Above screen has one Text box and one label to display our output return by the scanner machine.
C# Code:
public partial class MainPage : Form
{
public System.Windows.Forms.Timer tmrDelay;
public MainPage()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Trim().Length == 1)
{
tmrDelay.Enabled = true;
tmrDelay.Tick += new EventHandler(tmrDelay_Tick);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void tmrDelay_Tick(object sender, EventArgs e)
{
try
{
tmrDelay.Enabled = false;
string strCurrentString = textBox1.Text.Trim().ToString();
if (strCurrentString != "")
{
//Do something with the barcode entered
lblOutput.Text="Output : "+strCurrentString;
textBox1.Text = "";
}
textBox1.Focus();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void MainPage_Load(object sender, EventArgs e)
{
tmrDelay = new System.Windows.Forms.Timer();
tmrDelay.Interval = 1000;
tmrDelay.Enabled = false;
}
}
After adding above code we will get the output as given below.
Thanks for reading :)
No comments:
Post a Comment