471,354 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Text box to go to next tab index control

When the max length of a text box has been reached, I want the focus to go to
the next control based on tab index. How do I code or what property do I set?
Dec 7 '05 #1
2 19006
You could do something similar to the following.

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
if (this.textBox1.TextLength == this.textBox1.MaxLength)
{
this.SelectNextControl(this.textBox1, true, true, true, true);
}
}

--
Tim Wilson
..NET Compact Framework MVP

"Mike L" <Ca***@nospam.nospam> wrote in message
news:9D**********************************@microsof t.com...
When the max length of a text box has been reached, I want the focus to go to the next control based on tab index. How do I code or what property do I

set?
Dec 8 '05 #2
Tim Wilson wrote:
You could do something similar to the following.

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
if (this.textBox1.TextLength == this.textBox1.MaxLength)
{
this.SelectNextControl(this.textBox1, true, true, true, true);
}
}


I'd do it on KeyUp, because I believe TextChanged doesn't fire until the
control loses focus (i might be thinking of javascript though).

private void textBox1_KeyUp(object sender, KeyEventArgs e) {
if (textBox1.TextLength == textBox1.MaxLength) {
textBox2.Focus();
}
}

actually I just tried it and textchanged does work after every keypress.
So either TextChanged or KeyUp will work for you.
Dec 8 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Abhijeet Kumar | last post: by
5 posts views Thread by John Saunders | last post: by
8 posts views Thread by EEEdiot | last post: by
7 posts views Thread by ashkaan57 | last post: by
reply views Thread by RateTheBuilder | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.