i am trying to dynamically add checkboxes to a groupd box based on the amount of rows in a datatable. when looping through i get my first result but i am not able to get the next results to show...here is my code
Dim q As String
Dim qt As DataTable
Dim gbHeight As Integer = 40
Dim checkHG As Integer = 5
Dim checkHN As Integer = 5
q = "Select * from loads where filenumber = " & Shipments2.txtFileNumber.Text
qt = GetSQL(q)
For i = 0 To qt.Rows.Count - 1
Dim items As New List(Of LoadDetails)
Dim ld As New LoadDetails
items = ld.GetListBySQL("select * from loadDetails where LoadNumber = " & qt.Rows(i).Item("id"))
For Each item As LoadDetails In items
Dim checkgross = New CheckBox
Dim checknet = New CheckBox
gbHeight += 20
'add checkbox control to form
checkgross.Location = New Point(40, checkHG + 20)
checkgross.Text = item.Description & " (Gross)"
checkgross.Size = New Size(250, 20)
checkgross.Name = item.ProductCode.ToString & "-gross"
gbGross.Size = New Size(329, gbHeight)
gbGross.Controls.Add(checkgross)
rbPrintingNet.Location = New Point(rbPrintingNet.Location.X, rbPrintingNet.Location.Y + 40)
checknet.Location = New Point(40, checkHN + 20)
checknet.Text = item.Description & " (Net)"
checknet.Size = New Size(250, 20)
checknet.Name = item.ProductCode.ToString & "-net"
gbNet.Location = New Point(44, rbPrintingNet.Location.Y + 25)
gbNet.Size = New Size(329, gbHeight)
gbNet.Controls.Add(checknet)
Me.Size = New Size(Me.Size.Width, Me.Size.Height + 50)
Next
Next
All your controls are on directly top of each other:
checkgross.Location = New Point(40, checkHG + 20)
Since checkHG
never changes. Change the Location() for each dynamic control...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.