ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Rename Windows Form DataGridView Column Header text in C# and VB.Net<p>Hey <a class="username" rel="satabeach"> satabeach</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">public Form1() { InitializeComponent(); DataTable dt = BindGrid(); this.dataGridView1.DataSource = dt; dataGridView1.Columns[&#34;Name&#34;].HeaderText = &#34;CustomerName&#34;; } private DataTable BindGrid() { using (DataTable dt = new DataTable()) { dt.Columns.AddRange(new DataColumn[3] { new DataColumn(&#34;Id&#34;, typeof(int)), new DataColumn(&#34;Name&#34;, typeof(string)), new DataColumn(&#34;Country&#34;,typeof(string)) }); dt.Rows.Add(1, &#34;John Hammond&#34;, &#34;United States&#34;); dt.Rows.Add(2, &#34;Mudassar Khan&#34;, &#34;India&#34;); dt.Rows.Add(3, &#34;Suzanne Mathews&#34;, &#34;France&#34;); dt.Rows.Add(4, &#34;Robert Schidner&#34;, &#34;Russia&#34;); return dt; } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Public Sub New() InitializeComponent() Dim dt As DataTable = BindGrid() Me.dataGridView1.DataSource = dt Me.dataGridView1.Columns(&#34;Name&#34;).HeaderText = &#34;CustomerName&#34; End Sub Private Function BindGrid() As DataTable Using dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn(2) {New DataColumn(&#34;Id&#34;, GetType(Integer)), New DataColumn(&#34;Name&#34;, GetType(String)), New DataColumn(&#34;Country&#34;, GetType(String))}) dt.Rows.Add(1, &#34;John Hammond&#34;, &#34;United States&#34;) dt.Rows.Add(2, &#34;Mudassar Khan&#34;, &#34;India&#34;) dt.Rows.Add(3, &#34;Suzanne Mathews&#34;, &#34;France&#34;) dt.Rows.Add(4, &#34;Robert Schidner&#34;, &#34;Russia&#34;) Return dt End Using End Function</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/iDVyZ48.gif" alt="" width="356" height="264" /></p>https://www.aspforums.net:443/Threads/130791/Rename-Windows-Form-DataGridView-Column-Header-text-in-C-and-VBNet/https://www.aspforums.net:443/Threads/130791/Rename-Windows-Form-DataGridView-Column-Header-text-in-C-and-VBNet/Wed, 14 Nov 2018 23:44:05 GMT