Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

DataGridView Custom Headers in VB.NET

, 9 Mar 2009 CPOL
How to give Custom Headers to your DataGridView
DGVHeaderColor.zip
DGVHeaderColor
DGVHeaderColor
DGVHeaderColor.exe
DGVHeaderColor.pdb
DGVHeaderColor.vbproj.user
DGVHeaderColor.vshost.exe
My Project
Application.myapp
Settings.settings
Resources
AquaBall Blue.png
Button Gray Stripe 01 050.png
DGVHeaderColor.suo
Docs
Gradient ColumnHeader_files
4BBCD906-6DAD-4443-8F0B-525208645B30.jpg
add.gif
AddTo_Blink.png
AddTo_Delicious.png
AddTo_Digg.png
AddTo_Facebook.png
AddTo_Furl.png
AddTo_Google.png
AddTo_Live.png
AddTo_MrWong.png
AddTo_Newsvine.png
AddTo_Reddit.png
AddTo_Simpy.png
AddTo_stumbleupon.png
AddTo_Technorati.png
AddTo_Yahoo.png
ajax-loader.gif
BE.gif
discuss.gif
forum_faq.gif
forum_newmsg.gif
forum_search.gif
GradientColumnheader.png
javaduke.jpg
LAMP.GIF
link.png
logo225x90.gif
mail.gif
member_sm.gif
MonthlyComp.png
msg_admin.gif
msg_answer.gif
msg_general.gif
msg_joke.gif
msg_news.gif
msg_question.gif
msg_rant.gif
pollcol.gif
print.gif
red.gif
report.gif
ServeHTML_data
developer_express_60Free-Controls-150x80.swf
ServeHTML_data_002
B3424356_data
crystal-160x600.swf
ServeHTML_data_003
Dundas_468x60_Chart.swf
ServeLinks_data
smartclient24.jpg
smiley_confused.gif
smiley_laugh.gif
smiley_OMG.gif
smiley_smile.gif
smiley_wink.gif
t.gif
thumbs_down.gif
thumbs_up.gif
t_002.gif
watchon.png
white.gif
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
	Inherits System.Windows.Forms.Form

	'Form overrides dispose to clean up the component list.
	<System.Diagnostics.DebuggerNonUserCode()> _
	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
		Try
			If disposing AndAlso components IsNot Nothing Then
				components.Dispose()
			End If
		Finally
			MyBase.Dispose(disposing)
		End Try
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> _
	Private Sub InitializeComponent()
		Me.dgvData = New System.Windows.Forms.DataGridView
		Me.Column1 = New System.Windows.Forms.DataGridViewTextBoxColumn
		Me.Column2 = New System.Windows.Forms.DataGridViewTextBoxColumn
		Me.Column3 = New System.Windows.Forms.DataGridViewTextBoxColumn
		Me.Column4 = New System.Windows.Forms.DataGridViewTextBoxColumn
		Me.Column5 = New System.Windows.Forms.DataGridViewTextBoxColumn
		CType(Me.dgvData, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'dgvData
		'
		Me.dgvData.BackgroundColor = System.Drawing.Color.White
		Me.dgvData.ColumnHeadersHeight = 25
		Me.dgvData.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2, Me.Column3, Me.Column4, Me.Column5})
		Me.dgvData.Location = New System.Drawing.Point(0, 0)
		Me.dgvData.Name = "dgvData"
		Me.dgvData.RowHeadersVisible = False
		Me.dgvData.Size = New System.Drawing.Size(552, 303)
		Me.dgvData.TabIndex = 0
		'
		'Column1
		'
		Me.Column1.HeaderText = "Column1"
		Me.Column1.Name = "Column1"
		'
		'Column2
		'
		Me.Column2.HeaderText = "Column2"
		Me.Column2.Name = "Column2"
		'
		'Column3
		'
		Me.Column3.HeaderText = "Column3"
		Me.Column3.Name = "Column3"
		'
		'Column4
		'
		Me.Column4.HeaderText = "Column4"
		Me.Column4.Name = "Column4"
		'
		'Column5
		'
		Me.Column5.HeaderText = "Column5"
		Me.Column5.Name = "Column5"
		'
		'frmMain
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(587, 303)
		Me.Controls.Add(Me.dgvData)
		Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Margin = New System.Windows.Forms.Padding(4)
		Me.Name = "frmMain"
		Me.Text = "Form1"
		CType(Me.dgvData, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)

	End Sub
	Friend WithEvents dgvData As System.Windows.Forms.DataGridView
	Friend WithEvents Column1 As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents Column2 As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents Column3 As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents Column4 As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents Column5 As System.Windows.Forms.DataGridViewTextBoxColumn
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Luca Crisi, MCP
Software Developer (Senior)
Italy Italy
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 9 Mar 2009
Article Copyright 2009 by Luca Crisi, MCP
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid