1
Answer

Setting AcceptButton and CancelButton to the same button?

gyasimus

gyasimus

20y
2.8k
1
Is it possible to set the AcceptButton and CancelButton to only one and the same button on a windows form?
Answers (1)
1
Hirendra Sisodiya

Hirendra Sisodiya

238 8.1k 4.6m 14y
 

add reference od system.text.regularexpression

and then use this code: 

private void txtEmail_Leave(object sender, EventArgs e)

        {

            Regex mRegxExpression;

            if (txtEmail.Text.Trim() != string.Empty)

            {

                mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");

                if (!mRegxExpression.IsMatch(txtEmail.Text.Trim()))

                {

                    MessageBox.Show("E-mail address format is not correct.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtEmail.Focus();

                }

            }

        }

thanks

Please mark as answer if it helps

Accepted
0
Shivaraj Poojary

Shivaraj Poojary

NA 92 316.4k 14y
The information which u gave was very helpful...thanks a lot...
0
Hirendra Sisodiya

Hirendra Sisodiya

238 8.1k 4.6m 14y
0
Hirendra Sisodiya

Hirendra Sisodiya

238 8.1k 4.6m 14y
hello Shivraj

Regular expressions provide a powerful, flexible, and efficient method for processing text.
in above regular expression we can check input email id text format.

check this article on msdn:
http://support.microsoft.com/kb/308252

thanks
0
Shivaraj Poojary

Shivaraj Poojary

NA 92 316.4k 14y
if u dont mind can u give explanation for d below code...thank u... mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");