1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Dim ds As DataSet = Nothing
Dim dr As DataRow = Nothing
Dim Elem As String
Dim ElemCol As Integer = 0
Try
If Item Is Nothing Then
Return False
End If
'Verification of the mode before continue
If DataMode <> DATAMODE_ENUM.ssDataModeAddItem Then
Throw New Exception("You're not in DataModeAddItem. So you can't add new Item.")
Exit Function
End If
If MyBase.DataSource Is Nothing Then
ds = New DataSet
Else
ds = CType(MyBase.DataSource, DataSet)
End If
If (ds.Tables.Count) = 0 Then ds.Tables.Add()
dr = ds.Tables(0).NewRow
ds.Tables(0).Rows.Add(dr)
For i As Integer = Item.Split(Char.Parse(",")).Length - 1 + Item.Split(Char.Parse(";")).Length To dr.Table.Columns.Count + 1 Step -1
dr.Table.Columns.Add()
Next
For Each Elem In Item.Split(Char.Parse(","))
dr(ElemCol) = Elem
ElemCol = ElemCol + 1
For j As Integer = 1 To Elem.Split(Char.Parse(";")).Length - 1
If Cvn(dr(ElemCol - 1)).IndexOf(";"c) > -1 Then
dr(ElemCol - 1) = EsaLeft(Cvn(dr(ElemCol - 1)), Cvn(dr(ElemCol - 1)).IndexOf(";"c))
End If
dr(ElemCol) = Elem.Split(Char.Parse(";"))(j)
ElemCol = ElemCol + 1
Next
Next
MyBase.DisplayMember = Nothing
MyBase.DataSource = ds
Me.ColumnsAutoWidth(1)
Me.VisibleCols = Item.Split(Char.Parse(",")).Length
' make sure that the column headers will be visible or not
MyBase.Rows.Band.ColHeadersVisible = _blnHeadersVisible
Return True
Catch ex As Exception
efwErrHandler(ex)
Return False
End Try |
Partager