AspxGridView在cell内显示颜色

 protected void master_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
        {

            if (e.DataColumn.FieldName == "RGB值")
            {
                colors = e.CellValue.ToString();
               
            }
           
                if (e.DataColumn.FieldName == "颜色参照")
                {    var cc = colors.Split(',');
                    if (cc.Count() == 3)
                    {

                        try
                        {
                            byte R = Convert.ToByte(cc[0]);
                            byte G = Convert.ToByte(cc[1]);
                            byte B = Convert.ToByte(cc[2]);
                            Color endcolor = Color.FromArgb(R, G, B);
                            e.Cell.BackColor = endcolor;
                        }
                        catch (Exception we) { }
                    }
                }
         
                
        }

  

posted @ 2015-02-04 15:38  南修子  阅读(379)  评论(0编辑  收藏  举报