示例#1
0
 public static void SetGridStyle(DataGridView grid, GridTheme theme)
 {
     grid.DefaultCellStyle = new DataGridViewCellStyle(DefaultGridStyles);
     grid.AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle(AlternatingRowDefaultStyles);
     grid.AlternatingRowsDefaultCellStyle.SelectionBackColor = theme.CellAltSelectColor;
     grid.DefaultCellStyle.SelectionBackColor = theme.CellSelectColor;
     grid.Font = DefaultGridStyles.Font;
 }
示例#2
0
        public static void HighlightRow(DataGridView grid, GridTheme theme, int row)
        {
            if (row > -1)
            {
                var backColor   = grid.CurrentRow.InheritedStyle.BackColor;
                var selectColor = grid.CurrentRow.InheritedStyle.SelectionBackColor;

                var blendColorSelect = ColorAlphaBlend(theme.RowHighlightColor, selectColor);
                var blendColorBack   = ColorAlphaBlend(theme.RowHighlightColor, backColor);

                for (int i = 0; i < grid.Rows[row].Cells.Count; i++)
                {
                    grid.Rows[row].Cells[i].Style.SelectionBackColor = blendColorSelect;
                    grid.Rows[row].Cells[i].Style.BackColor          = blendColorBack;
                }
            }
        }