I'm trying to increase the value in the textbox by using arrowkeys. I'm using wfp, c#
if (ke.Key == Key.Up || ke.Key == Key.Down)
ke.Handled = false;// need a method in here
How can I increase the value in the textbox using arrow keys?
I'm trying to increase the value in the textbox by using arrowkeys. I'm using wfp, c#
if (ke.Key == Key.Up || ke.Key == Key.Down)
ke.Handled = false;// need a method in here
How can I increase the value in the textbox using arrow keys?
The texbox in WPF
<TextBox Name="textbox1" HorizontalAlignment="Left" Text="0" Height="23" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Margin="154,138,0,0" PreviewKeyDown="TextBox_KeyDown"/>
CodeBehind
private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
int currentNumber = Convert.ToInt32(textbox1.Text);
if (e.Key == Key.Up)
{
textbox1.Text = (currentNumber + 1).ToString();
}
else if (e.Key == Key.Down)
{
textbox1.Text = (currentNumber - 1).ToString();
}
}