AutoValidate a Textbox

  • Thread starter Thread starter Gene Vital
  • Start date Start date
G

Gene Vital

Hey all,

I am looking for a way to have a textbox autovalidate once the number
of characters entered is == MaxLength. As it is now you have to hit tab
to go to the next control.
 
Eugene Vtial said:
I would have to know what the next control that would need to receive
the focus is though.

Look at the Form.GetNextControl method for this.
Chris Jobson
 
Chris said:
Look at the Form.GetNextControl method for this.
Chris Jobson
Ok, I have... how do I reference the current form that the control is on?

If it were a Container Control I could use the ParentForm propert.
 
Gene Vital said:
Ok, I have... how do I reference the current form that the control is on?

Control.FindForm() - though if you're doing this logic in the in the
TextBox's KeyUp event then the event handler is normally a member of the
Form class containing the TextBox, so you can just call GetNextControl (or
use "this.GetNextControl" if you want to be more explicit).

Chris Jobson
 
Chris said:
Control.FindForm() - though if you're doing this logic in the in the
TextBox's KeyUp event then the event handler is normally a member of the
Form class containing the TextBox, so you can just call GetNextControl (or
use "this.GetNextControl" if you want to be more explicit).


I found a much simpler way to achieve what I needed

if ( this.SelectionStart == this.MaxLength && this.Text.Length ==
..MaxLength)
this.Parent.SelectNextControl(this, true, false, true, true);


thanks for all the good tips though :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top