Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want Validation in DataGridview Cell for which i want to enter only below value of 100 in that cell....(cell is for like inputing Percentage)
i dont want to enter greater than 100 to do that

1 solution


One way to do it is to use the CellValidating event.

See here:[^]

you could do it like that:

private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
    if (e.ColumnIndex == _indexOfColumnTocheck)
        int value;
        if (int.TryParse((string)e.FormattedValue, out value))
            if (value > 100) { e.Cancel = true; }
            e.Cancel = true;

Share this answer
jayeshhh 12-Sep-13 9:23am    
Thank You

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900