2
votes

I need to display a column called Full Name in the my datagridview, but the datasource (datatable) does not have a FullName column. It only has FirstName and LastName columns. I'm setting up my DataGridView like this:

        Dim column As DataGridViewColumn = New DataGridViewTextBoxColumn()
        column.DataPropertyName = "?" //Need FirstName + " " + LastName
        column.Name = "FullName"
        dgv.Columns.Add(column)

How can I set the DataPropertyName to use data from both the FirstName and LastName columns in the datatable.?

Thanks.

1

1 Answers

4
votes

One way to do this is to use a calculated data column

  1. Add a new DataColumn called FullName.
  2. Set the Expression property to FirstName + ' ' + LastName
  3. Set the DataPropertyName to FullName