日期:2014-05-18  浏览次数:20872 次

C# 表名发货单,列名利润,利润列数据小于0的单元格显示红色
private void 发货单DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  {
  if (e.Value == null)
  return;
  if (发货单DataGridView.Columns[e.ColumnIndex].Name = "利润" && int.Parse(e.Value.ToString() < 0))
  {
  e.CellStyle.BackColor = Color.Red;
  }
  }

int.Parse(e.Value.ToString() < 0) 报错,错误 1 运算符“<”无法应用于“string”和“int”类型的操作数 C:\Users\wangxin\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs 43 81 WindowsFormsApplication3

请问如何修改,


------解决方案--------------------
int.Parse(e.Value.ToString()) < 0
------解决方案--------------------
探讨
int.Parse(e.Value.ToString()) < 0

------解决方案--------------------
强制转化下不就可以的吗
------解决方案--------------------
探讨
int.Parse(e.Value.ToString()) < 0