i tried to customize the column name because the column name in my datagridview comes directly from the table column name, which is kindda odd. i browse throught this forum and other forums on howto's but i get this wierd error.

Dim dgTS As New DataGridTableStyle
        Dim ColStyle As New DataGridTextBoxColumn

        ColStyle.MappingName = "empID"
        ColStyle.HeaderText = "Employee ID"

        DataGridView1.TableStyles.Add(dgTS) 'error here, green underline

tablestyles is not a member of system.windows.form.datadridview do i have to add additinal reference to my project?

please help..

You're mixing DataGrid with DataGridView.
DataGridView does not have a .TableStyles property

how do i give a custom column to my datagridview then? please advice

Here is a technique:

Public Class Form1

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      DataGridView1.Columns.Add("asdf", "myASDF")
      DataGridView1.Columns(0).Width = 444

      For i As Integer = 0 To 3
         DataGridView1.Rows(i).Cells(0).Value = "adsf"

      Dim style As New DataGridViewCellStyle With {.ForeColor = Color.Red}

      DataGridView1.Rows(0).Cells(0).Style = style
      DataGridView1.Rows(2).Cells(0).Style = style
   End Sub
End Class

Error: Rows cannot be add programatically When control is databound??
besides this adds new column, what i want is to rename the data table field name.
orderID(field name) to Order ID(custom)

Edited 4 Years Ago by steplar: n/a

Finally get the solution. For anyone who have this problem, the solution is simple.

myDataTable.Columns(0).Name = "Name of the first column"

This change the default database field/column names.

This question has already been answered. Start a new discussion instead.