Displaying field name in datagridview

  • Thread starter Thread starter SF
  • Start date Start date
S

SF

Hi,

In my first attemp to work with VB.NET, I have attached tables to
datagridview. Data has been display succesfully but my problem is that the
field names is displaying as header of the table of the datagrid. Is there a
way to change the displayed header to the one that is readable such as
change from Ck_Project_ID to Project ID etc...
If so how would I do that

SF
 
Yes. In the designer window select your grid, then click on the small
triangle on the right top corner and set the properties you like.

Gilbert
 
You can assign headers in your code like this:


DataGridView1.DataSource = datatable123
DataGridView1.Columns(0).HeaderText = "Account #"
DataGridView1.Columns(1).HeaderText = "Customer Name"
DataGridView1.Columns(1).HeaderText = "Whatever"

This way you can make them dynamic should you need to reuse the
datagridview for more than one datasource.

-T
 
Thank for your advice.

SF

Mr. Taco said:
You can assign headers in your code like this:


DataGridView1.DataSource = datatable123
DataGridView1.Columns(0).HeaderText = "Account #"
DataGridView1.Columns(1).HeaderText = "Customer Name"
DataGridView1.Columns(1).HeaderText = "Whatever"

This way you can make them dynamic should you need to reuse the
datagridview for more than one datasource.

-T
 
Back
Top