十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
你可以在读数据库阶段,就处理该列数据,用Select case when这样的SQL语句实现,这样无需后期处理,速度快很多。
创新互联公司主营新洲网站建设的网络公司,主营网站建设方案,重庆App定制开发,新洲h5微信平台小程序开发搭建,新洲网站营销推广欢迎新洲等地区企业咨询
是可以的,先把datagridview清空,再把表赋给它,它会自动列改为你赋给它的表的列标题的,如果想单独改的话就用DataGridView.Columns(index).HeaderText
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGridView1.Columns.Clear()
DataGridView1.DataSource = GetDateTable("1|2|3,张三|李四|王五,1111111|2222222|3333333", "编号|姓名|卡号")
End Sub
Function GetDateTable(ByVal s As String, ByVal TabNames As String) As DataTable
Dim tb As New DataTable
Dim ss() As String = s.Split(",")
Dim tc() As String = TabNames.Split("|")
Dim c As Integer
For Each i As String In ss
Dim ts() As String = i.Split("|")
Dim dc As DataColumn
If c tc.Length Then
dc = New DataColumn(tc(c))
Else
dc = New DataColumn
End If
tb.Columns.Add(dc)
For j As Integer = 0 To ts.Length - 1
If j tb.Rows.Count - 1 Then
tb.Rows.Add(tb.NewRow)
End If
tb.Rows(j)(dc) = ts(j)
Next
c += 1
Next
Return tb
End Function