我正在使用 LINQ 填充我的 DataGridView,并且我想要自定义标题(其中将包含空格)。
想要的结果
这就是我的 DataGridView 标头应如下所示:
构建我的 DataGridView
Private db As New Data.Linq.DataContext("Data Source=SQL01;Initial Catalog=Test;Integrated Security=True")
Private Articles As Table(Of Article) = db.GetTable(Of Article)()
Private Manufacturers As Table(Of Manufacturer) = db.GetTable(Of Manufacturer)()
Private Providers As Table(Of Provider) = db.GetTable(Of Provider)()
Private Sub btnLoad_Click(sender As System.Object, e As System.EventArgs) Handles btnLoad.Click
Dim allArticles = _
From a In Articles
Join m In Manufacturers
On a.FK_Manufacturer Equals (m.PK_Manufacturer)
Join p In Providers
On a.FK_Provider Equals (p.PK_Provider)
Select Article = a.ArtNum, Description = a.Description, Pièce = a.PartNum, _
Manufacturier = m.Name, Coût = a.Cost, Fournisseur = p.Name, _
a.FlagMech, a.FlagStandard, a.FlagAvaible, a.Notes, a.CodeRSPL
DataGridView1.DataSource = allArticles
End Sub
当前结果
我一直试图让我的标题只有 1 个单词,例如Article或Pièce而不是# Article或# de pièce。
我尝试执行以下操作:
Select [# Article] = article.ArtNum, ... 'Error; Identifier expected
Or
Select ["# Article"] = article.ArtNum, ... 'Error; Identifier expected
Or
Select "# Article" = article.ArtNum, ... 'Error; Range variable name can be inferred only from a simple or qualified name with no arguements
我正在尝试使用 LINQ 吗?