有一个类型为GroupType
的数组gGroupArray Public Structure GroupType
Dim bChecked As Boolean
Dim iCategoryID As Short
Dim tProductGroup As String
End Structure
Public gGroupArray() As GroupType
数据存储在gGroupArray中。有一个名为GroupGrid的数据网格视图
With GroupGrid
Dim objCB As New DataGridViewCheckBoxColumn
With objCB
.Name = "CB"
End With
.Columns.Add(objCB)
Dim objProductGroup As New DataGridViewTextBoxColumn
With objProductGroup
.Name = "ProductGroup"
End With
.Columns.Add(objProductGroup)
Dim objCategoryId As New DataGridViewTextBoxColumn
With objCategoryId
.Name = "CategoryID"
End With
.Columns.Add(objCategoryId)
End With
GroupGrid.RowCount = UBound(gGroupArray)
GroupGrid.Rows.Add(GroupGrid.RowCount)
我必须将gGroupArray数据存储到GroupGrid中。如何做到这一点。
谢谢
答案 0 :(得分:0)
首先创建三个列,然后使用以下代码:
Public Sub Load_Items(ByRef Array() As GroupType, ByRef DataGrid As DataGridView)
For Each Item As GroupType In Array
With Item
DataGrid.Rows.Add(.bChecked, .iCategoryID, .tProductGroup)
End With
Next
End Sub
第一个参数是 gGroupArray ,第二个参数是 DataGridView名称。
告诉我它是否有效! :)