Question:
Hi, I have a couple questions about text boxs.
1. How do I make a limit of characters in a text box? ex. Limit of 5 numbers in a text box.
2. How can I make it have a limit of one character in a text box, but still be able have other characters? ex. a decimal in a calculator.
3. How can I select a text box and add characters by pressing a character button? ex. press a number button and it will appear in the selected text box.
Thanks in advance.
Answer1:
1) Have a look at the KeyDown, KeyUp and TextChanged properties
2) Have a look at the KeyDown, KeyUp and TextChanged properties
3)Have a look at the Text property and depending on exactly what you want then maybe also the Focus method
Hope this helps.
Answer2:
Can you explain it to me more or give an example. I am very new to C#.
Answer3:
Hi,
1. use the MaxLength property of the TextBox (default 32767). You find this property if you select the TextBox in the Form Designer and look for MaxLength in the Properties Window.
2. I don't really understand what you want to do. Can you give me an example?
3. Double click the Button in the Form Designer generates a click event handler. You can change the value of the TextBox by accessing the Text property.
example
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text +
"xyz"; // adds xyz to the value of the textbox
}
regards
Philipp
Answer4:
Thanks for the help. I now have it all working.