C#lisview,蓝色和红色写作 [英] C# lisview, blue and red writing

查看:97
本文介绍了C#lisview,蓝色和红色写作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我正在使用C#作为我的工作项目,我遇到了一个问题,我想写的报警是红色的,警告是蓝色的。我解决了这个问题但是那里是另一个问题。在这种情况下,第一个警报不符合序列。我怎么能解决这个问题。



我试过的:



Hi friends,
I am using C# for my work projects and I faced a problem that I would like to write for Alarm is Red and for warning is Blue.I solved it like this but there is an another problem.In the case ,first alarm doesn't fit in to the sequence.How can I solve this problem.

What I have tried:

if(Convert.ToBoolean(M3177) && rep[0])
            {
                A1.Text = now;
                A1.SubItems.Add(alarms[0]);
                A1.ForeColor = listViewRed;
                rep[0] = false;
            }

            if (Convert.ToBoolean(M3176) && rep[1])
            {
                A2.Text = now;
                A2.SubItems.Add(alarms[1]);
                A2.ForeColor = listViewRed;
                rep[1] = false;
            }

            if (Convert.ToBoolean(M3175) && rep[2])
            {
                A3.Text = now;
                A3.SubItems.Add(alarms[2]);
                A3.ForeColor = listViewRed;
                rep[2] = false;
            }

            if (Convert.ToBoolean(M3174) && rep[3])
            {
                A4.Text = now;
                A4.SubItems.Add(alarms[3]);
                A4.ForeColor = listViewRed;
                rep[3] = false;
            }

            if (Convert.ToBoolean(M3173) && rep[4])
            {
                A5.Text = now;
                A5.SubItems.Add(alarms[4]);
                A5.ForeColor = listViewRed;
                rep[4] = false;
            }

            listView1.Items.Clear();
            listView1.Items.AddRange(new ListViewItem[] { A1, A2, A3, A4, A5 });

推荐答案

好的我解决了,



Okay I solved it,

if (Convert.ToBoolean(M3176) && rep[1])
            {
                A2.Text = now;
                A2.SubItems.Add(alarms[1]);
                A2.ForeColor = listViewRed;
                rep[1] = false;
                listView1.Items.Add(A2);
            }


这篇关于C#lisview,蓝色和红色写作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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