SIGN UP MEMBER LOGIN:    
Blog

Add Image on DatagridView cell Header

Posted by Ankur Gupta Blogs | Active Directory in VB.NET May 31, 2010
Add Image on DatagridView cell Header
Download Files: ImageOnGridCell.zip

Datagrid view does not have any property by which we can add an Image on DataGrid View Header.

But we can add Image on data grid view programetically.

We will use CellPainting Event of data grid view to add the image.

Declare an Image vriable

Dim InfoIcon As Image = Image.FromFile("C:\AddEmoticons04247.gif")

 'Replace C:\AddEmoticons04247.gif with your Image File Path.

Use the following code to Add image on Header.

If e.RowIndex = -1 AndAlso e.ColumnIndex = MyDataGridView.Columns.Count - 1 Then

                e.Paint(e.CellBounds, DataGridViewPaintParts.All And Not DataGridViewPaintParts.ContentForeground)

                e.Graphics.DrawImage(InfoIcon, e.CellBounds)

                e.Handled = True

            End If
ImageOnGridHeader.JPG

share this blog :
post comment