TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
anna john
NA
47
9k
row validating not letting form to close if a new row added
Oct 11 2019 5:17 PM
after validating if all fields are available in a datagridview row, using RowValidating event; if the user accidently clicks on a new row, then the validations are triggered and not letting form to close.
Below is the code
private void dgv1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if (dgv1.CurrentRow != null)
{
DataGridViewRow dgvRow = dgv1.CurrentRow;
if (dgvRow.Cells["txtEmpName"].Value == DBNull.Value)
{
MessageBox.Show("Employee Name cannot be empty");
e.Cancel = true;
}
}
}
the user enters one row successfully and clicks on next row. then row validation triggers and not letting form to close.
Reply
Answers (
3
)
event to validate datagridview rows
How to Check a Particular Element has a Value or elements ?