Advertisement
Advertisement
| 01.13.2008 at 02:52PM PST, ID: 23079648 |
|
[x]
Attachment Details
|
||
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: |
Private Delegate Sub AddRowDelegate(ByRef row As DataGridViewRow)
public sub new()
Me.InventoryGrid.Rows.Clear()
Me.MyThread = New Threading.Thread(New Threading.ThreadStart(AddressOf Me.LoadInventoryGrid))
Me.MyThread.Start()
end sub
Private Sub AddRow(ByRef row As DataGridViewRow)
If Me.InvokeRequired Then
Dim usd As New AddRowDelegate(AddressOf Me.AddRow)
Me.Invoke(usd, New Object() {row})
Else
' This is where the code crashes
InventoryGrid.Rows.Add(row)
End If
End Sub
Public Sub LoadInventoryGrid()
'read from my database into an arraylist
' loop through the arraylist creating a row, adding cells as i go
dim my_list as new arraylist
dim r as datagridviewrow
for i as integer=0 to my_list / count -1
r=new datagridviewrow
dim c as new datagridviewtextboxcell
c.value=1 ' some value
r.cells.add(c)
next i
' add the row
addrow(r)
end sub
|