I have 20 TextBoxes in a form. And I have a Common KeyPress Event for all of that Textboxes.
So I try to declare the keypress event like the following manner… is it possible?
for (int Cnl = 1; Cnl < 21; Cnl++)
{
((RichTextBox)Cnl).KeyPress += new KeyPressEventHandler(this.Comn_KeyPress);
}
Correct idea; but casting an int to a RichTextBox will never work. Try this: