.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Problem in DataGridView Cell Validation in c#

Posted By: Naim Khan     Posted Date: January 01, 2010    Points:2   Category :Windows Application
Hello every one,

I have One Data GridView. i want to Make Validation on Cell . Cell is Accept only Numaric and Decimal Values and is should not be Greater than of 100 if its Greater Than 100 than give me MSG... i donthave any idea of this Validation if u know than please let me know as soon as possible...

Thanks In Advance

Author: Faizal             
Posted Date: January 02, 2010     Points: 5   

Hi Naim,

yes you can validate datagridview cell like this

private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
// Validate the CompanyName entry by disallowing empty strings.
if (dataGridView1.Columns[e.ColumnIndex].Name == "CompanyName")
if (e.FormattedValue == null &&
dataGridView1.Rows[e.RowIndex].ErrorText =
"Company Name must not be empty";
e.Cancel = true;

void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
// Clear the row error in case the user presses ESC.
dataGridView1.Rows[e.RowIndex].ErrorText = String.Empty;

you can modify the above code depend upon your requirement


Author: Naim Khan             
Posted Date: January 05, 2010     Points: 5   

thanks for the reply but i don't want that sir. i just want only double values and it should not be grater
than 100. thats it i want... so if you have any idea than let me know

thanks in Advance

Naim Khan

Software Developer

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend