我如何使用这个昏暗的句柄作为我需要处理newpritemnobox的列表。那就是当我从newpritemnobox组合框中选择时,在某些选择newpritemnobox中包含podesc将显示
Public Class POfrm
Dim newpritemnobox As New List(Of ComboBox)
Dim newpodescbox As New List(Of RichTextBox)
Private Sub controlall(ByVal controlcount As Integer)
Dim boxpritemno As ComboBox
Dim boxpodesc As RichTextBox
For i As Integer = 1 To controlcount
boxpritemno = New ComboBox
boxpritemno.Size = New Drawing.Size(51, 21)
boxpritemno.Location = New Drawing.Point(89, 542 + 58 * (i - 1))
newpritemnobox.Add(boxpritemno)
Me.Controls.Add(boxpritemno)
Next
For i As Integer = 1 To controlcount
boxpodesc = New RichTextBox
boxpodesc.Size = New Drawing.Size(442, 45)
boxpodesc.Location = New Drawing.Point(323, 542 + 58 * (i - 1))
newpodescbox.Add(boxpodesc)
Me.Controls.Add(boxpodesc)
Next
End Sub
Private Sub poitemno_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles poitemno.Click
Dim msgboxresponse As MsgBoxResult
msgboxresponse = MsgBox("Are You Sure of the number of Item you choose?Please Check Again", _
MsgBoxStyle.Question + MsgBoxStyle.YesNo, Me.Text)
If msgboxresponse <> MsgBoxResult.Yes Then
Else
controlall(Val(txtpoitemno.Text))
txtpoitemno.Enabled = False
poitemno.Enabled = False
loadtrypritemno()
Return
End If
End Sub
我想这是我的代码,但它既不显示错误也不显示
Private Sub boxpounitprice_SelectedIndexChanged(ByRef boxpritemno As ComboBox)
datab = "Select pritemno from prpo where pritemno = '" & boxpritemno.Text & "'"
connDB()
cmd = New OleDbCommand(datab, conn)
Dim result As Object
result = cmd.ExecuteScalar()
If result IsNot Nothing Then
boxpoqty.Text = result.ToString()
End If
End Sub
Private Sub loadtrypritemno()
Dim controlall As Integer = Val(txtpoitemno.Text)
'start from 0 because it's 0-based index
For i As Integer = 0 To controlall - 1
' addbuyer(Label(i), itemcode(i), boxes(i), qty(i), combo(i), statusboxes(i), Remarksboxes(i))
boxpounitprice_SelectedIndexChanged(newpritemnobox(i))
AddHandler newpritemnobox(i).SelectedIndexChanged, AddressOf boxpounitprice_SelectedIndexChanged
Next
End Sub
Private Sub boxpounitprice_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tb As ComboBox = CType(sender, ComboBox)
tb.SelectAll()
MsgBox()
End Sub
'Private Sub loadamounttext()
' ' addpo()
'End Sub
Private Sub loadprinaccountcode()
Dim datab4 As String
Dim cmd4 As OleDbCommand
Try
Dim ST As String = cmbprno.SelectedText
End Sub
Private Sub loadpritem(ByRef boxpritemno As ComboBox)
Try
datab = "Select pritemno from prpo where prno = '" & cmbprno.Text & "'"
connDB()
cmd = New OleDbCommand(datab, conn)
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
boxpritemno.Items.Clear()
Do While dr.Read = True
' txtdepartadd.Items.Add(dr("Departmentname"))
boxpritemno.Items.Add(dr(0))
Loop
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
End Class
答案 0 :(得分:0)
Private Sub boxty()
Dim controlall As Integer = Val(txtpoitemno.Text)
For i As Integer = 0 To controlall - 1
boxpounitprice_SelectedIndexChanged(newpritemnobox(i), newpoqtybox(i))
Next
End Sub
Private Sub boxpounitprice_SelectedIndexChanged(ByRef boxpritemno As ComboBox, ByRef boxpoqty As TextBox)
AddHandler boxpritemno.SelectedIndexChanged, AddressOf boxpritemno_selectedindex
End Sub
Private Sub boxtrytry(ByVal boxpritemno As ComboBox, ByRef boxpoqty As TextBox, ByRef boxpounit As ComboBox, ByRef boxpodesc As RichTextBox)
Dim datab1 As String
Dim cmd1 As OleDbCommand
Dim datab2 As String
Dim cmd2 As OleDbCommand
Try
datab = "Select prqty from prpo where pritemno = '" & boxpritemno.Text & "' and prno = '" & cmbprno.Text & "'"
connDB()
cmd = New OleDbCommand(datab, conn)
Dim result As Object
result = cmd.ExecuteScalar()
If result IsNot Nothing Then
' txtendorsedby.Text = result.ToString()
boxpoqty.Text = result.ToString()
End If
datab1 = "Select pruom from prpo where pritemno = '" & boxpritemno.Text & "' and prno = '" & cmbprno.Text & "'"
connDB()
cmd1 = New OleDbCommand(datab1, conn)
Dim result1 As Object
result1 = cmd1.ExecuteScalar()
If result1 IsNot Nothing Then
' txtendorsedby.Text = result.ToString()
boxpounit.Text = result1.ToString()
End If
datab2 = "Select prdesc from prpo where pritemno = '" & boxpritemno.Text & "' and prno = '" & cmbprno.Text & "'"
connDB()
cmd2 = New OleDbCommand(datab, conn)
Dim result2 As Object
result2 = cmd2.ExecuteScalar()
If result2 IsNot Nothing Then
' txtendorsedby.Text = result.ToString()
boxpodesc.Text = result2.ToString()
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
Private Sub loadtrypritemno()
' MessageBox.Show("right")
Dim controlall As Integer = Val(txtpoitemno.Text)
For i As Integer = 0 To controlall - 1
boxtrytry(newpritemnobox(i), newpoqtybox(i), newpounitbox(i), newpodescbox(i))
Next
End Sub