Iam creating this project which uses on screen keyboard. The problem is I have several textboxes in my window. The question is, when I selected the textbox and start using the on screen keyboard, the text should be displayed on the textbox that I selected.
there will be a possibility that not all the textbox are being used depending on the user's preference.
Here's my sample code when I click the button
private void button_numeric_1_Click(object sender, RoutedEventArgs e)
{
if (txtThousand.Focus())
{
txtThousand.Text += "1";
// txtThousand.Focus();
txtThousand.SelectionStart = txtThousand.Text.Length;
}
else if (txtFivehundred.Focus())
{
txtFivehundred.Text += "1";
txtFivehundred.Focus();
txtFivehundred.SelectionStart = txtThousand.Text.Length;
}
}
My problem now is how can I determine which text box is active.
When I used this code:
private void StartKeyBoardProcess(TextBox tb)
{
try
{
if (tb != null)
{
MessageBox.Show("Pumasok!");
tb.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show("Error");
}
}
private void txtThousand_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TextBox tb = sender as TextBox;
StartKeyBoardProcess(tb);
}
Nothing happens.
When I Click my button, It only input text in the First Textbox. When I click the other textbox, It continue inputting in the first text box.
Can anyone tell me how to work this out? I'm so new with WPF.