Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

How to set DataGridView Background Color to transparent color?

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TransparentDataGridView // Change this to your namespace!
    class dGV : DataGridView      // class name then ': DataGridView'
        protected override void PaintBackground(Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
            base.PaintBackground(graphics, clipBounds, gridBounds); Rectangle rectSource = 
                new Rectangle(this.Location.X, this.Location.Y, this.Width, this.Height);
            Rectangle rectDest = new Rectangle(0, 0, rectSource.Width, rectSource.Height);
            Bitmap b = new Bitmap(Parent.ClientRectangle.Width, Parent.ClientRectangle.Height);
            Graphics.FromImage(b).DrawImage(this.Parent.BackgroundImage, Parent.ClientRectangle);
            graphics.DrawImage(b, rectDest, rectSource, GraphicsUnit.Pixel);
        public void SetCellsTransparent()
            this.EnableHeadersVisualStyles = false;
            this.ColumnHeadersDefaultCellStyle.BackColor = Color.Transparent;
            this.RowHeadersDefaultCellStyle.BackColor = Color.Transparent;
            this.DefaultCellStyle.BackColor = Color.Transparent;
            this.DefaultCellStyle.SelectionBackColor = Color.Transparent;
            //foreach (DataGridViewColumn col in this.Columns)
            //    col.DefaultCellStyle.BackColor = Color.Transparent;
            //    col.DefaultCellStyle.SelectionBackColor = Color.Transparent;

Comments are closed, but trackbacks and pingbacks are open.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More