gpt4 book ai didi

c# - 如何在 Gridview 文本上使用大于号?

转载 作者:太空宇宙 更新时间:2023-11-03 23:28:00 24 4
gpt4 key购买 nike

我有一个像这样的 Gridview:

enter image description here

Zero 行大于 %10 时,我需要更改背景颜色。

我这样试过(只有 15%):

if (e.Row.Cells[0].Text == "Zero")
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].Text == "15%")
{
e.Row.Cells[i].BackColor = System.Drawing.Color.LightCoral;
}
}
}

由于 %,我无法将 Row.Cells[i].Text 转换为 Int。如何使用大于 10 的背景颜色?

最佳答案

只是替换

if (e.Row.Cells[i].Text == "15%")

if (int.Parse(e.Row.Cells[i].Text.Trim('%'))>10)

关于c# - 如何在 Gridview 文本上使用大于号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33215355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com