我正在使用 Microsoft 的 Northwind 数据库进行练习。我尝试将表中的值填充到 Truedbgrid 中。这仍然有效,但后来我注意到 3 列有一个crlf
. 我试图用 REPLACE 来解决它,但它没有用。
我将查询(在数据集中)从
SELECT ContactID, ContactType, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Extension, Fax, HomePage, PhotoPath, Photo FROM dbo.Contacts
至
SELECT ContactID, ContactType, CompanyName, ContactName, ContactTitle, REPLACE(Address,CHAR(13)+CHAR(10),' '), City, Region, PostalCode, Country, Phone, Extension, Fax, HomePage, PhotoPath, Photo FROM dbo.Contacts
另一种我不知道的方式。我在互联网上搜索,如果有办法对 truedbgrid 说,删除所有crlf
. 但我什么也没找到。在表中是crlf
看不见的。我无法删除它。有什么想法吗?
我的 VB.NET 类代码:
Private Sub tdbgContactsParamentrieren()
Try
With tdbgContacts
.AllowAddNew = False
.AllowDelete = False
.AllowColMove = False
.AllowFilter = True
.AllowSort = True
.MultiSelect = MultiSelectEnum.None
.AllowUpdate = True
.AllowUpdateOnBlur = True
.FilterBar = True
.RowHeight = 22
.TabAction = TabActionEnum.ColumnNavigation
.MarqueeStyle = MarqueeEnum.HighlightCell
.Columns(0).Caption = "ID"
.Columns(1).Caption = "Type"
.Columns(2).Caption = "Company"
.Columns(3).Caption = "Name"
.Columns(4).Caption = "Title"
.Columns(5).Caption = "Address"
.Columns(6).Caption = "City"
.Columns(7).Caption = "Region"
.Columns(8).Caption = "Postal Code"
.Columns(9).Caption = "Country"
.Columns(10).Caption = "Phone"
.Columns(11).Caption = "Extension"
.Columns(12).Caption = "Fax"
.Columns(13).Caption = "Home Page"
.Columns(14).Caption = "Photo Path"
With .Splits(0)
.AlternatingRowStyle = True
.EvenRowStyle.BackColor = Color.LightYellow
.EvenRowStyle.VerticalAlignment = AlignVertEnum.Center
.OddRowStyle.VerticalAlignment = AlignVertEnum.Center
.ColumnCaptionHeight = 30
.DisplayColumns(0).Width = 42 'ID
.DisplayColumns(1).Width = 52 'Type
.DisplayColumns(2).Width = 218 'Company
.DisplayColumns(3).Width = 168 'Name
.DisplayColumns(4).Width = 168 'Title
.DisplayColumns(5).Width = 150 'Country
.DisplayColumns(6).Width = 257 'Address
.DisplayColumns(8).Width = 56 'PostalCode
.DisplayColumns(9).Width = 168 'City
.DisplayColumns(10).Width = 90 'Phone
.DisplayColumns(11).Width = 56 'Extension
.DisplayColumns(12).Width = 93 'Fax
.DisplayColumns(13).Width = 200 'HomePage
For index As Integer = 0 To .DisplayColumns.Count - 1
.DisplayColumns(index).HeadingStyle.HorizontalAlignment = AlignHorzEnum.Center
.DisplayColumns(index).Locked = True
Next
End With
End With
Catch ex As Exception
End Try
End Sub
那就是,在我做出改变之前。
当我这样做时:
SELECT ContactID, ContactType, CompanyName, ContactName, ContactTitle, REPLACE(Address,CHAR(13)+CHAR(10),' '), City, Region, PostalCode, Country, Phone, Extension, Fax, HomePage, PhotoPath, Photo FROM dbo.Contacts
或者
SELECT ContactID, ContactType, CompanyName, ContactName, ContactTitle, REPLACE(REPLACE(Address, CHAR(13), ' '), CHAR(10), ' '), City, Region, PostalCode, Country, Phone, Extension, Fax, HomePage, PhotoPath, Photo FROM dbo.Contacts
或者
SELECT ContactID, ContactType, CompanyName, ContactName, ContactTitle, REPLACE(REPLACE(cast(Address as nvarchar(max)), CHAR(13), ' '), CHAR(10), ' '), City, Region, PostalCode, Country, Phone, Extension, Fax, HomePage, PhotoPath, Photo FROM dbo.Contacts
编辑2:
我需要表格“联系人”。