I have a datagrid called "grEmployeeList" on a form. I can display the data returned by sql. The problem is I can't display customized header text in a datagrid. Can someone tell me what I am doing wrong?
Table "Person" fields--Person_ID, FName, LName, Name_Kanji, Prefix, .....Phone_Number....Membership_Type
Table "Employee_Person" fields --Person_ID, Comp_ID, Title, Employee_Memo, Phone, Extension
CompID = frmSearch.SelectedCompID
---------------------------------------------------
'display employee names in datagrid
strSQL = "SELECT Person.Person_ID, Person.LName, Person.FName, Person.Name_Kanji, Person.Phone_Number FROM Person, Employee_Person WHERE Employee_Person.Comp_ID = " & CompID & "AND Employee_Person.Person_ID = Person.Person_ID"
Dim da As New OleDbDataAdapter(strSQL, cnJBSD)
Dim dsP As New DataSet
da.Fill(dsP)
Dim tblstyle As New DataGridTableStyle
tblstyle.MappingName = "Person"
Dim col1 As New DataGridTextBoxColumn
col1.MappingName = "Person_ID"
col1.HeaderText = "ID"
col1.Alignment = HorizontalAlignment.Center
col1.Width = 60
tblstyle.GridColumnStyles.Add(col1)
Dim col2 As New DataGridTextBoxColumn
col2.MappingName = "LName"
col2.HeaderText = "Last Name"
col2.Alignment = HorizontalAlignment.Center
col2.Width = 60
tblstyle.GridColumnStyles.Add(col2)
Dim col3 As New DataGridTextBoxColumn
col3.MappingName = "FName"
col3.HeaderText = "First Name"
col3.Alignment = HorizontalAlignment.Right
col3.Width = 60
tblstyle.GridColumnStyles.Add(col3)
Dim col4 As New DataGridTextBoxColumn
col4.MappingName = "Name_Kanji"
col4.HeaderText = "Name"
col4.Alignment = HorizontalAlignment.Center
col4.Width = 60
tblstyle.GridColumnStyles.Add(col4)
Dim col5 As New DataGridTextBoxColumn
col5.MappingName = "Phone_Number"
col5.HeaderText = "Phone Number"
col5.Alignment = HorizontalAlignment.Right
col5.Width = 60
tblstyle.GridColumnStyles.Add(col5)
grEmployeeList.TableStyles.Add(tblstyle)
grEmployeeList.DataSource = dsP.Tables(0).DefaultView
----------------------------------------------------------
Table "Person" fields--Person_ID, FName, LName, Name_Kanji, Prefix, .....Phone_Number....Membership_Type
Table "Employee_Person" fields --Person_ID, Comp_ID, Title, Employee_Memo, Phone, Extension
CompID = frmSearch.SelectedCompID
---------------------------------------------------
'display employee names in datagrid
strSQL = "SELECT Person.Person_ID, Person.LName, Person.FName, Person.Name_Kanji, Person.Phone_Number FROM Person, Employee_Person WHERE Employee_Person.Comp_ID = " & CompID & "AND Employee_Person.Person_ID = Person.Person_ID"
Dim da As New OleDbDataAdapter(strSQL, cnJBSD)
Dim dsP As New DataSet
da.Fill(dsP)
Dim tblstyle As New DataGridTableStyle
tblstyle.MappingName = "Person"
Dim col1 As New DataGridTextBoxColumn
col1.MappingName = "Person_ID"
col1.HeaderText = "ID"
col1.Alignment = HorizontalAlignment.Center
col1.Width = 60
tblstyle.GridColumnStyles.Add(col1)
Dim col2 As New DataGridTextBoxColumn
col2.MappingName = "LName"
col2.HeaderText = "Last Name"
col2.Alignment = HorizontalAlignment.Center
col2.Width = 60
tblstyle.GridColumnStyles.Add(col2)
Dim col3 As New DataGridTextBoxColumn
col3.MappingName = "FName"
col3.HeaderText = "First Name"
col3.Alignment = HorizontalAlignment.Right
col3.Width = 60
tblstyle.GridColumnStyles.Add(col3)
Dim col4 As New DataGridTextBoxColumn
col4.MappingName = "Name_Kanji"
col4.HeaderText = "Name"
col4.Alignment = HorizontalAlignment.Center
col4.Width = 60
tblstyle.GridColumnStyles.Add(col4)
Dim col5 As New DataGridTextBoxColumn
col5.MappingName = "Phone_Number"
col5.HeaderText = "Phone Number"
col5.Alignment = HorizontalAlignment.Right
col5.Width = 60
tblstyle.GridColumnStyles.Add(col5)
grEmployeeList.TableStyles.Add(tblstyle)
grEmployeeList.DataSource = dsP.Tables(0).DefaultView
----------------------------------------------------------