如何将DataGridView单元格值字符串转换为int [英] How to convert DataGridView cell value string to int

查看:748
本文介绍了如何将DataGridView单元格值字符串转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将datagridview单元格值字符串转换为整数,我希望比较单元格值大于或等于给定的整数值。

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.

推荐答案

尝试:

Try:
int value;
string str = MyDataGridView.Rows[2].Cells[4].Value.ToString();
if (int.TryParse(str, out value))
    {
    if (value > 666)
        {
        ...
        }
    }


这篇关于如何将DataGridView单元格值字符串转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆