如何为行提供前景色和背景色 [英] how to give forecolor and background color for row

查看:95
本文介绍了如何为行提供前景色和背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输出如下;





日期会议RK Mk CK Gk VK CMK CNN UNNi VB GS CM JN CA



1/7/12 1 REO Tasco AFF

1/7/12 2 REO Tasco AFF

1/7 / 12 3 REO Tasco AFF

1/7/12 4 REO Tasco AFF



1/8/12 1 REO Tasco AFF
1/8/12 2 REO Tasco AFF

1/8/12 3 REO Tasco AFF

1/8/12 4 REO Tasco AFF



来自输出



前色为浅蓝色和背底色为天蓝色1/7 / 12日期

前色在1/8/12日期有浅棕色和背底颜色为紫色





为1/7/12 1到4会话给出前面颜色和背景颜色不同。

for 1/8/12 1到4会话给出前面颜色和背景颜色不同。

Output as follows;


Date Session RK Mk CK Gk VK CMK CNN UNNi VB GS CM JN CA

1/7/12 1 REO Tasco AFF
1/7/12 2 REO Tasco AFF
1/7/12 3 REO Tasco AFF
1/7/12 4 REO Tasco AFF

1/8/12 1 REO Tasco AFF
1/8/12 2 REO Tasco AFF
1/8/12 3 REO Tasco AFF
1/8/12 4 REO Tasco AFF

from the output

fore color has light blue and back ground color as Sky Blue in 1/7/12 date
fore color has light brownand back ground color as purple in 1/8/12 date


for 1/7/12 1to 4 session give fore color and background color different.
for 1/8/12 1to 4 session give fore color and background color different.

推荐答案

如果你使用的是winforms,那就更好了你实现了你想要的东西吗?



我不完全确定最后一部分是什么意思,因为我不知道1到4会话意味着什么。



适用于1/7/12 1到4个会话,颜色和背景颜色不同。

适用于1/8/12 1到4个会话,颜色和背景颜色不同。



If you are using winforms this would be how you achieve what you are looking for.

Im not entirely sure what the last part means as i dont know what 1 to 4 session means.

"for 1/7/12 1to 4 session give fore color and background color different.
for 1/8/12 1to 4 session give fore color and background color different."

private void gridview_RowStyle(object sender, RowStyleEventArgs e)
{
    GridView View = sender as GridView;
    if (e.RowHandle >= 0)
    {
        string searchOne  = View.GetRowCellDisplayText(e.RowHandle, View.Columns["1/7/12"]);
        string searchTwo  = View.GetRowCellDisplayText(e.RowHandle, View.Columns["1/8/12"]);

        if (searchOne == "1/7/12")
        {
            e.Appearance.BackColor = Color.SkyBlue;
            e.Appearance.ForeColor = Color.LightBlue;
        }

        if (searchOne == "1/8/12")
        {
            e.Appearance.ForeColor = Color.Brown;
            e.Appearance.BackColor = Color.Purple;
        }
    }
}


这篇关于如何为行提供前景色和背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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