Click here to Skip to main content
15,886,783 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have datagridview which contains total 14 columns out of which first 9 columns are filled from one table("datafile") and other 5 columns i have added programatically as shown below.

VB
Dim col_Prof As New DataGridViewTextBoxColumn()
            With col_Prof
                .Name = "xx"
                .HeaderText = "xx"
                .ReadOnly = False
            End With
            dgvUserDetails.Columns.Add(col_Prof)


Now I want this column to be filled from another table("Prof") and bind to grid.Is it possible to do so?if yes how?
Posted
Updated 21-Dec-12 21:18pm
v4

1 solution

this way...
VB
Dim col_Prof As New DataGridViewTextBoxColumn()
With col_Prof
    .Name = "xx"
    .HeaderText = "xx"
    .ReadOnly = False
    .DataPropertyName = "Column1"  ' here name of column from datatable
End With
dgvUserDetails.Columns.Add(col_Prof)

dgvUserDetails.AutogenerateColumns = false
dgvUserDetails.Datasource = Ds.Tables(0)

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900