Bonjour

J'aimerais donner aux Header de colonnes des datagridview un look the toolstrip (Gradient Color)

J'utilise déja l'event CellPainting pour dessiner une image plutot que du texte
Mais je n'ai pas encore capté comment changer le Backround

Merci pour vos suggestions

Exemple pour l'image foreground
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
          if (e.ColumnIndex == 0)
          {
            Image ey = Properties.Resources.Eye;
            e.PaintBackground(e.ClipBounds, false);
 
            Point pt = e.CellBounds.Location;  
            int offset = (e.CellBounds.Width - ey.Size.Width) / 2;
            pt.X += offset;
            pt.Y += 1;
            e.Graphics.DrawImage(ey, pt);
            e.Handled = true;
          }
          else if ( e.ColumnIndex == 2)
          {
            Image ey = Properties.Resources.Rainbow2;
            e.PaintBackground(e.ClipBounds, false);
 
            Point pt = e.CellBounds.Location;  
            int offset = (e.CellBounds.Width - ey.Size.Width) / 2;
            pt.X += offset;
            pt.Y += 1;
 
            Rectangle R = new Rectangle(0, 0, ey.Size.Width, ey.Size.Height);
            e.Graphics.DrawImage(ey,e.CellBounds,R,GraphicsUnit.Pixel);
            e.Handled = true;
          }