效果圖:
為山亭等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及山亭網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都做網(wǎng)站、山亭網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
//偶數(shù)隨機(jī) Random evenRanm = new Random(); //奇數(shù)隨機(jī) Random oddRanm = new Random(); string[] listColor = new string[] { "#2BB669","#FF5750","#39AFEA","#9A0089", "#00CC6A","#717FF9","#4A5459","#00B7C3", "#0078D7","#E2AB12" }; //記載窗體執(zhí)行 //偶數(shù)集合 ListevenNum=new List (); //奇數(shù)集合 List oddNum = new List (); for (int j = 0; j < listColor.Count(); j++) { if (j % 2 == 0) { evenNum.Add(listColor[j]); } else { oddNum.Add(listColor[j]); } } //對(duì)List賦值 List list = new List (); list.Add(new Role_Info() { Role_Name= "超級(jí)管理員"}); list.Add(new Role_Info() { Role_Name= "超級(jí)用戶" }); list.Add(new Role_Info() { Role_Name = "教師" }); list.Add(new Role_Info() { Role_Name="院長(zhǎng)"}); list.Add(new Role_Info() { Role_Name = "校長(zhǎng)" }); list.Add(new Role_Info() { Role_Name = "普通用戶" }); list.Add(new Role_Info() { Role_Name = "Test" }); list.Add(new Role_Info() { Role_Name = "用戶" }); list.Add(new Role_Info() { Role_Name = "測(cè)試用戶" }); list.Add(new Role_Info() { Role_Name = "Student" }); list.Add(new Role_Info() { Role_Name = "Teacher" }); list.Add(new Role_Info() { Role_Name = "游客" }); list.Add(new Role_Info() { Role_Name = "學(xué)生" }); Button btn=null; for (int i = 0; i < list.Count; i++) { btn = new FButton(); if (i%2==0) { int even = evenRanm.Next(evenNum.Count()); btn.Content=list[i].Role_Name; btn.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(evenNum[even])); } else { int odd = oddRanm.Next(oddNum.Count()); btn.Content=list[i].Role_Name; btn.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(oddNum[odd])); } } //最后將Button添加到控件
總結(jié)
以上所述是小編給大家介紹的C# 根據(jù)表格偶數(shù)、奇數(shù)加載不同顏色,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!