I have a dataGrid which is bound to a contact table. The contact table has an ID value (integer) but the company name is stored in a second parent table called company. As it is a parent relation it has a one to one relation so it should be possible to lookup the company name and display it in the datagrid row and hide the ID number column. But how?
My Datagrid.ItemsSource is a List (of dataset.contacts table) and I am unsure if I can add a column to this array - although this would be the easiest way to achieve what I want.
I can add a column to the datagrid
Dim CompanyColumn AsNewSystem.Windows.Controls.DataGridTextColumn
With CompanyColumn
.header = "company name"
End With
DataGrid1.columns.add(companyColumn)
but can't figure out how to give it values (which I could do this in Windows forms using code like :-
companyName = dataset.company.findbyCompanyID(datagridview(i,"CompanyID").companyName
datagridview(i,"companyName").value=companyName
where i would be a loop counter, and I have added the "companyName" column to the datagridView. WPF Allows me to add the column but doesn't seem to allow me to treat the DataGrid as an array, and sets each rows value).
Is there a way to do this? I am happy to use a parent expression to get the companyName or to manually search for each rows value as above.
I am using VB code behind but if anyone answering this prefers to use C# thats OK.
Any tips or pointers will be gratefully recieved.