Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to validate and focus each text box alone
Mohamed Said
Nov 9 2017 8:48 AM
186
Reply
- i have two Texbox (1)Name, (2)Code. i want to validate each textbox alone but the code didn't work. every time show the first messagebox when i repeat Name OR Code
Code:-
if (dt.Rows.Count > 0 || dt2.Rows.Count > 0)
{
if (dt.Rows.Count > 0)
{
MessageBox.Show("this Name was inserted !", "Warning ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_Name.Focus();
txt_Name.SelectionStart = 0;
txt_Name.SelectionLength = txt_Name.TextLength;
return;
}
else if (dt2.Rows.Count > 0)
{
MessageBox.Show("That Code was inserted !", "Warning ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_Code.Focus();
txt_Code.SelectionStart = 0;
txt_Code.SelectionLength = txt_Code.TextLength;
return;
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Add Windows Form Login Page
how to Display Images in Rdlc Textbox in windows application