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
Ankit Agarwal
NA
379
248.1k
How to clear datagridview typed cell value in c# .net window
Sep 5 2013 6:30 AM
Hello,
How to clear datagridview typed cell value in c# .net windows application?
I have a datagridview in my application i am validating our datagridview for numneric value,
I am using this code:-
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridViewTextBoxCell cell = dataGridView1[6, e.RowIndex] as DataGridViewTextBoxCell;
if (cell != null)
{
if (e.ColumnIndex == 6)
{
char[] chars = e.FormattedValue.ToString().ToCharArray();
foreach (char c in chars)
{
if (char.IsDigit(c) == false)
{
MessageBox.Show("You have to enter digits only");
e.Cancel = true;
break;
}
}
}
}
}
}
But i have a problem with this, when we typed in cell so it did not clear cell after the message show,
I have to press, Backspace key for clear the cell.
I want to automatically cleared after wrong entry or "MessageBox.Show("You have to enter digits only");" this message show.
How it can be possible?
Please help me.
Thanks in Advance
Ankit Agarwal
Software Engineer
Reply
Answers (
2
)
Showing connection string in textfield
How to break a program before called to Main()?