471,627 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Custom Text Box go to next Text Box

Custom text box to go to next text box in tab list. When the user types in a
text box and the max length is meet, the focus goes to the next text box in
the tab list. Here is my code so far, but I don't know what to put in the
first parameter of SelectNextControl, noted with a question mark.

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
this.SelectNextControl(?, true, true, true, true);
}
}

Dec 8 '05 #1
3 2449
Mike L,

Just pass this for the first parameter, to start at the current control
(since it is assumed you have focus at that point).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike L" <Ca***@nospam.nospam> wrote in message
news:95**********************************@microsof t.com...
Custom text box to go to next text box in tab list. When the user types
in a
text box and the max length is meet, the focus goes to the next text box
in
the tab list. Here is my code so far, but I don't know what to put in the
first parameter of SelectNextControl, noted with a question mark.

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
this.SelectNextControl(?, true, true, true, true);
}
}

Dec 8 '05 #2
No errors, but the focus does not go to the next control when the max length
is meet.

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);

if (this.Text.Length == this.MaxLength)
{
this.SelectNextControl(this, false, true, true, true);
}
}
}


"Nicholas Paldino [.NET/C# MVP]" wrote:
Mike L,

Just pass this for the first parameter, to start at the current control
(since it is assumed you have focus at that point).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike L" <Ca***@nospam.nospam> wrote in message
news:95**********************************@microsof t.com...
Custom text box to go to next text box in tab list. When the user types
in a
text box and the max length is meet, the focus goes to the next text box
in
the tab list. Here is my code so far, but I don't know what to put in the
first parameter of SelectNextControl, noted with a question mark.

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
this.SelectNextControl(?, true, true, true, true);
}
}


Dec 9 '05 #3
Mike L wrote:
No errors, but the focus does not go to the next control when the max length
is meet.

class ClassTextBox : System.Windows.Forms.TextBox
{
protected override void OnEnter(System.EventArgs e)
{
base.OnEnter(e);
SelectAll();
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);

if (this.Text.Length == this.MaxLength)
{
this.SelectNextControl(this, false, true, true, true);
}
}
}


Change your code to
this.FindForm().SelectNextControl(this, false, true, true, true);
--
Tom Porterfield
Dec 9 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ron Andersen | last post: by
16 posts views Thread by Bret Pehrson | last post: by
reply views Thread by Oded Dror | last post: by
11 posts views Thread by Pete Kane | last post: by
1 post views Thread by RSH | last post: by
1 post views Thread by XIAOLAOHU | 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.