I am trying to create a custom datagridview control in VB.net. When the control is bound I want to use the caption of the datatable column rather than the field name in the datagrid view header. I can't figure out how to get to the data binding. Here is a sample of what i'm trying to do:
Private Sub MyGrid_DataBind ingComplete(ByV al sender As Object, ByVal e As System.Windows. Forms.DataGridV iewBindingCompl eteEventArgs) Handles Me.DataBindingC omplete
Dim ds As DataSet
Dim bs As BindingSource
'The next 2 line just don't work
bs = DataBindings(Me .DataSource)
ds = bs.DataSource
For Each c As DataGridViewCol umn In Me.Columns
c.HeaderText = x.Tables(Me.Dat aMember).Column s(c.DataPropert yName).Caption
Next
End Sub
Private Sub MyGrid_DataBind ingComplete(ByV al sender As Object, ByVal e As System.Windows. Forms.DataGridV iewBindingCompl eteEventArgs) Handles Me.DataBindingC omplete
Dim ds As DataSet
Dim bs As BindingSource
'The next 2 line just don't work
bs = DataBindings(Me .DataSource)
ds = bs.DataSource
For Each c As DataGridViewCol umn In Me.Columns
c.HeaderText = x.Tables(Me.Dat aMember).Column s(c.DataPropert yName).Caption
Next
End Sub