Hello,
In VS2003, I tried using an enum and setting it into a field in a
datarow. It seems as if the datatype of the field in the row
determined what went into the field. If the datatype was string, then
the name of the enum item went into the field, but if the datatype was
integer, then the integer value of the enum was stored.
Is this expected behaviour? I couldn't find anything while searching
for answers.
TIA
Barry
'Here is a sample to demonstrate
'option strict and option explicit are on in all files
Public Class testclass2
Public Enum TESTENUM
AA = 1
BB = 2
End Enum
'And other code
End Class
'this is called in a separate form
Private Sub showthis()
Dim dd As System.Data.Dat aRow
Dim cc As System.Data.Dat aColumn
Dim tt As System.Data.Dat aTable
tt = New System.Data.Dat aTable
cc = New System.Data.Dat aColumn
With cc
.AllowDBNull = False
.DataType = System.Type.Get Type("System.St ring")
.ColumnName = "string"
End With
tt.Columns.Add( cc)
cc = New System.Data.Dat aColumn
With cc
.AllowDBNull = False
.DataType = System.Type.Get Type("System.In t32")
.ColumnName = "integer"
End With
tt.Columns.Add( cc)
Dim aa() As Object
ReDim aa(1)
aa(0) = "ss"
aa(1) = 100
tt.Rows.Add(aa)
With tt
.Rows(0).Item(" string") = testclass2.TEST ENUM.AA
System.Windows. Forms.MessageBo x.Show(.Rows(0) .Item("string") .ToString)
.Rows(0).Item(" integer") = testclass2.TEST ENUM.AA
System.Windows. Forms.MessageBo x.Show(.Rows(0) .Item("integer" ).ToString)
End With
End Sub
bceggersATcomca stDOTnet