How to set header name of datagridview vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • medibatam
    New Member
    • Jul 2012
    • 1

    How to set header name of datagridview vb.net

    I used the vb.net 2008
    I want to set the header name of my datagridview when connect to my database.

    here is the problem..
    field name of database is "item_code" also show the same in data gridgridview..

    I want to change it to be "Item Code" in datagridview, but i don't kow how to code it. When i change it manually the data from database not appear..pls help me solve this..
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Just go into your database and change that value like so "Item Code";

    Comment

    • Mudassir
      New Member
      • May 2012
      • 85

      #3
      you can add an item template or Bound Field in the grid view to bind the data, and set the header text of item template or bound field to Item Code
      ...
      Addan

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Mudassir, a DataGridView is not the same as a ASP.NET GridView and does not use item templates.

        Anyways, the DataGridView has DataGridViewCol umns and a DataGridViewCol umn has a HeaderText Property that you can use to set the column's headers.

        So, loop through the columns in your DataGridView, find the one with the header text that you don't like, and change it :)

        -Frinny

        Comment

        • Mudassir
          New Member
          • May 2012
          • 85

          #5
          Pardon me , i thought it a grid view of asp.net..

          Comment

          Working...