I'm working on a user interface for a database. For reasons I am copying database tables into my own dataset, and from there I am querying across those tables to join them. This works (except for some type problems, but that isn't the focus here), but I want the column headers of my DataGridView to have up to two words per header (for a pretty display).
Here's the query :
Dim query = _
From bidInfo In dataset.Tables("BidInfo").AsEnumerable() _
Join projectInfo In dataset.Tables("ProjectInfo").AsEnumerable() _
On projectInfo.Field(Of String)("Project") Equals bidInfo.Field(Of String)("Project") _
Join contractorInfo In dataset.Tables("ContractorInfo").AsEnumerable() _
On contractorInfo.Field(Of String)("Contractor") Equals bidInfo.Field(Of String)("Contractor") _
Join contactInfo In dataset.Tables("ContactInfo").AsEnumerable() _
On contactInfo.Field(Of String)("Contractor") Equals bidInfo.Field(Of String)("Contractor") And contactInfo.Field(Of String)("Contractor Contact") Equals bidInfo.Field(Of String)("Contractor Contact")
Select New With { _
.BidNumber = projectInfo.Field(Of String)("BidNumber"), _
.Project = projectInfo.Field(Of String)("Project"), _
.TimeDue = projectInfo.Field(Of String)("TimeDue"), _
.Architect = projectInfo.Field(Of String)("Architect"), _
.ArchitectPhone = projectInfo.Field(Of String)("ArchitectPhone")}
I then use
dataGridView1.DataSource = query.ToList
This all shows up nice except for the two-word column headings (BidNumber, TimeDue, ArchitectPhone). How do I get a space in them? I've tried having brackets on the member names and such, but it doesn't like that.
There must be a syntax I'm missing, but I haven't found it from my limited research (generally people say that spaces in field names are a bad idea, but this is for display).
As a second part, why does the DataGridView display nothing when I have a field(Of Double)?
Thank you in advance for any help.
EDIT: I've found a temporary solution in a question that was already asked (How to Set Custom DataGridView Headers (with spaces) using LINQ?) that it seems I have duplicated =/ The solution provided manually goes through the columns and re-sets the headers. This has the same outcome I want, but I would prefer to minimize the number of things I have to change if I add a column to the database. If anyone has a way to just start with the correct column headers, that would be great. If not, no worries, and thanks for taking the time to read all the text =)