How To set Header Text in DataGrid Window Application. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How To set Header Text in DataGrid Window Application.

Chandan ThourChandan Thour Posts: 20Member
Hi There,

How can we set the Header Text of a DataGrid in a Window Application.

In My application. User will insert information in the cells of datagrid from where it will be stored in db. So Dataset stuff is not valid.

I need to write my columns Header name by myself.

Setting the Header text is the only problem i am facing. Can anyone help?


  • munirshahzadmunirshahzad Posts: 59Member
    There are two ways to do it.
    Select DataGrid, comes to Properties and click on TableStyles. Click Add to add a table style. Now Click GridColumnStyle. Here again Click Add to add a column Style. In column Style Properties you have a property HeaderText.

    Public Class frmEditEmployeeCourses

    Dim Table_Style_Once As Boolean = True

    Sub DataGrid()
    Dim Educational_Da As New SDS.OleDbDataAdapter("Select * from Customers", Courses_Cn)
    Dim Educational_Ds As New DataSet()
    Educational_Da.Fill(Educational_Ds, "Customers")
    If Me.Table_Style_Once Then
    Me.Table_Style_Once = False
    End If
    Me.dgBrowseCourses.DataSource = Educational_Ds.Tables("Customers")
    Me.dgBrowseCourses.CaptionText = "Customers Found : " & Me.BindingContext(Educational_Ds, "Customers").Count
    Catch Ex As Exception
    MsgBox(Ex.Message, MsgBoxStyle.Critical, "DataGrid Error")
    End Try
    End Sub

    Sub DataGrid_Styles()
    Dim grdColStyle1 As New DataGridTextBoxColumn()

    With grdColStyle1 : .HeaderText = "Customer Name" : .MappingName = "CName" : .Width = 34 : End With

    Dim grdTableStyle1 As New DataGridTableStyle()
    grdTableStyle1.MappingName = "Customers"

    grdTableStyle1.GridColumnStyles.AddRange _
    (New DataGridColumnStyle() _
    End Sub
    End Class
Sign In or Register to comment.