both will have different event arguments, so it will not work. have separate method for the key press event.
On Thu, Apr 9, 2009 at 1:53 PM, VIKAS GARG <[email protected]> wrote: > Hi friends I am developing an application in which there is a text box, in > this text box I need to have telephone number as an input. So for this I > need to put a constarint on this text box so that it will only accept > integers and not other and also there shold be the c ondition so that no > more than 10 digits could be given.... > > When I double click on the text box for writing code for the event, the > event which apears is TextChanged event. and after reading several > tutoprials on the google about adding such constraint I found that "* > KeyPress*" event should be used. but when I change this "*TextChange"* to > "KeyPress" in Form1.cs and form1.Designer.cs then also it is not working. I > have also tried to use regular expression but that also didn't work for me. > > using System; > using System.Collections.Generic; > using System.ComponentModel; > using System.Data; > using System.Drawing; > using System.Text; > using System.Windows.Forms; > > namespace WindowsApplication10 > { > public partial class Form1 : Form > { > public Form1() > { > InitializeComponent(); > } > > private void Form1_Load(object sender, EventArgs e) > { > > } > > private void text1_TextChanged(object sender, EventArgs e) > { > > } > } > } > > > The above is the code > > in my form I have defined only two fields one is label and the other is > text box.... > > Please help me in putting both the constraint.......... > > -- By Dhanapal
