Click here to Skip to main content
15,892,804 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to convert datagridview cell value string to integer and i want compare the cell value is greater than or equal to the given integer value.
Posted
Comments
Suvendu Shekhar Giri 5-Aug-15 1:44am    
So, have you tried anything?
Have you tried read documentation or a doing a simple google search?
Patrice T 5-Aug-15 1:54am    
I allow you to do it.

1 solution

Try:
C#
int value;
string str = MyDataGridView.Rows[2].Cells[4].Value.ToString();
if (int.TryParse(str, out value))
    {
    if (value > 666)
        {
        ...
        }
    }
 
Share this answer
 
v2
Comments
Mekalamani 5-Aug-15 2:12am    
Thank You for the Reply

But I got error "Object Reference is Not Set as Instance of an object" in this line string str = MyDataGridView.Rows[2].Cells[4].Value.ToString();
OriginalGriff 5-Aug-15 2:18am    
Obviously, I have no idea what row or column you are trying to address to find your cell...so "2" and "4" were there as placeholders for you to replace with the appropriate values...
Mekalamani 5-Aug-15 3:17am    
I replaced CurrentRow for instead of Rows[2]
Thank You
Its work fine
OriginalGriff 5-Aug-15 3:32am    
You're welcome!

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