创建一个多色“进度条” [英] Create a multicolor "progress bar"
本文介绍了创建一个多色“进度条”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表格的大多数示例都显示了如何添加行。我需要添加颜色代表4种完成状态的列。我想要的是并排添加固定宽度的盒子,其颜色取决于条件。
当我将标签移动到foreach之后时,以下代码有效环。但这会导致添加行。
我得到一个HTML错误结束标记tr没有匹配的开始。我试图在代码中而不是在css中执行此操作。
Most examples of tables show how to add rows. I need to add columns whose colors represent 4 states of completion. What I want to is add fixed width "boxes" side by side whose color depends on the condition.
The following code works when I move the tag to after the foreach loop. But that causes rows to be added.
I get an HTML error "end tag "tr" with no matching start. I'm trying to do this in the code rather than in css.
<table>
<colgroup style =" width:50px"></colgroup>
@{ var rowColor = "D9E6C4"; }
<tr>
@foreach (var item in Model.Tasks)
{
if (item.SStart == null)
{ rowColor = "#fff8c6"; }
else if (item.SStart != null && item.SEnd == null)
{ rowColor = "#c0c0c0";} //="background-color:silver">}
else if (item.SEnd != null && item.SCert == null)
{ rowColor ="#5cb3ff";} //"background-color:blue">}
else if (item.SCert != null)
{ rowColor = "#4aa02c";} //style="background-color:green">}
//now add the data
<td style="background-color:@rowColor;" >
</td>
</tr>
};
</table>
新手所以请明确提出建议
谢谢
A newbie so please be explicit with suggestions
Thanks
推荐答案
我的解决方案 - 这种方法不起作用
所以我将使用图形类从中创建位图图像数据,然后使用普通表构造将其显示为行数据。
感谢您的期待。
JW
My solution - this approach won't work
So I'll use the graphics class to create a bitmap image from the data, then use the normal table construct to display it as row data.
Thanks for looking.
JW
这篇关于创建一个多色“进度条”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文