Edward Barnes
Newcomer
I can fill a DataGrid from an Array (rather than a dataset) in VB.NET but I can't seem to get the items in the array to display in DataGrid columns in a specific order. No matter what I do, they always display in the same order. Here's what I did:
1) in a Module, I coded:
Structure StateData
Public StateName As String
Public StateCode As String
Public CountryCode As String
ReadOnly Property StCode()
Get
Return StateCode
End Get
End Property
ReadOnly Property StName()
Get
Return StateName
End Get
End Property
ReadOnly Property CtryCode()
Get
Return CountryCode
End Get
End Property
End Structure
Public StateRecord() As StateData
Public Sub FillStateRecord()
ReDim StateRecord(2)
StateRecord(0).CountryCode = "USA"
StateRecord(0).StateCode = "NM"
StateRecord(0).StateName = "New Mexico"
StateRecord(1).CountryCode = "USA"
StateRecord(1).StateCode = "TX"
StateRecord(1).StateName = "Texas"
StateRecord(2).CountryCode = "USA"
StateRecord(2).StateCode = "WY"
StateRecord(2).StateName = "Wyoming"
End Sub
2) In a form with a DataGrid, in the form load event, I coded:
FillStateRecord()
DataGrid1.DataSource = StateRecord
Does anyone have any idea how to make these display in a specified order? I tried using DataGrid1.DataMember but haven't figured out how to do it.
1) in a Module, I coded:
Structure StateData
Public StateName As String
Public StateCode As String
Public CountryCode As String
ReadOnly Property StCode()
Get
Return StateCode
End Get
End Property
ReadOnly Property StName()
Get
Return StateName
End Get
End Property
ReadOnly Property CtryCode()
Get
Return CountryCode
End Get
End Property
End Structure
Public StateRecord() As StateData
Public Sub FillStateRecord()
ReDim StateRecord(2)
StateRecord(0).CountryCode = "USA"
StateRecord(0).StateCode = "NM"
StateRecord(0).StateName = "New Mexico"
StateRecord(1).CountryCode = "USA"
StateRecord(1).StateCode = "TX"
StateRecord(1).StateName = "Texas"
StateRecord(2).CountryCode = "USA"
StateRecord(2).StateCode = "WY"
StateRecord(2).StateName = "Wyoming"
End Sub
2) In a form with a DataGrid, in the form load event, I coded:
FillStateRecord()
DataGrid1.DataSource = StateRecord
Does anyone have any idea how to make these display in a specified order? I tried using DataGrid1.DataMember but haven't figured out how to do it.