Hello All
i have windows App
some text boxs
i tab between textbox by this code
private void AstTxt_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
AltTxt.Focus();
}
}
but i want when go next text box
select data in this textbox not delete it

Ramadan Elmahdy27 reputationPosted Mar 17, 2015, 12:45 PM EDT
private void AstTxt_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
AltTxt.Focus();
AltTxt.SelectionStart = 0;
AltTxt.SelectionLength = AltTxt.Text.Length;
}
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 17, 2015, 8:11 PM EDT
Hi,
you can also write this code in Enter event of text box
private void textBox1_Enter(object sender, System.EventArgs e){
if (!String.IsNullOrEmpty(textBox1.Text))
{
textBox1.SelectionStart = 0;
textBox1.SelectionLength = textBox1.Text.Length;
}
}
hope this will help you.