Windows Develop Bookmark and Share   
 index > Windows Forms Designer > hi pls help me to limit my textbox as only integer 8 digit not less then 8
 

hi pls help me to limit my textbox as only integer 8 digit not less then 8

hi pls help me to limit my textbox as only integer 8 digit not less then 8

in vb.net.

I cant use maskedtextbox for that because we have userControls to use.

reply me soon thanks this is for phone number

jalpa  Thursday, May 29, 2008 6:32 AM

Hi,

You can implement the KeyDown event handler of your TextBox control and perform a check operation.

Code Snippet

private void Form1_Load(object sender, EventArgs e)
{
textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
}

void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if(textBox1.Text.Length > 8)
{
MessageBox.Show("No more that 8 digits");
}
}

Regards,

Jacob

Jacob Sui - MSFT  Monday, June 02, 2008 7:13 AM

Hi,

You can implement the KeyDown event handler of your TextBox control and perform a check operation.

Code Snippet

private void Form1_Load(object sender, EventArgs e)
{
textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
}

void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if(textBox1.Text.Length > 8)
{
MessageBox.Show("No more that 8 digits");
}
}

Regards,

Jacob

Jacob Sui - MSFT  Monday, June 02, 2008 7:13 AM

You can use google to search for other answers

Custom Search

More Threads

• Understanding ZOrder
• creating a windows basesd webservice using vb.net
• Inherited Control
• Common Langauge Runtime Debugging Services
• Form designer does not handle Generic List properties of custom controls... ???
• Expert evaluation required : CanParent, OnParentChanged workaround
• What's wrong with the designer ?
• Adding Design mode (Toolstrip) on C# Windows Custom Control
• Form resized by IDE
• Three D Buttons