我有文字框但不是同一种形式。第一个文本框是登录表单中的staffid。第二个文本框是销售形式的员工名字。
admin staffid的名字是Ng
我在下面插入代码:
Private Sub txtId_TextChanged(sender As Object, e As EventArgs) Handles txtId.TextChanged
Sale.Staff_First_NameTextBox.Text = "select [Staff First Name] from staff where Staffid ='" & txtId.Text.Trim & "'"
End Sub 当我在staffid文本框中插入admin时,在Staff_First_NameTextBox中显示的东西是
"select [Staff First Name] from staff where Staffid ='admin'"
应该是Ng ......
任何人都可以提供帮助吗?
答案 0 :(得分:0)
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text.Trim.Contains("Moves Like Jagger") = True Then
TextBox1.Text = "90 Dollars"
ElseIf ComboBox1.Text.Trim.Contains("Titanium") = True Then
TextBox1.Text = "120 Dollars"
End If
End Sub
答案 1 :(得分:0)
Dim Cls as New DatabaseQueries
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text.Trim = Cls.getDataInDB("SELECT PRICE FROM tblSongs WHERE SONG = '" & ComboBox1.Text.Trim & "'")
End Sub
'===========================Inside the Class DatabaseQueries===================
Public Function getDataInDB(ByVal sQuery As String) As String
getDataInDB = Nothing
Try
CMD = New SqlCommand(sQuery, TestResult)
Dim sqlAdapter As SqlDataAdapter
Dim dataS As DataSet
sqlAdapter = New SqlDataAdapter(CMD)
dataS = New DataSet
sqlAdapter.Fill(dataS, "getRecord")
getDataInDB = dataS.Tables("getRecord").Rows(0).ItemArray(0).ToString()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
这是想法= D
答案 2 :(得分:0)
哦,好的,对不起,我没有注意到这些变化。你现在遇到的问题被称为表单冻结事件,这意味着表单完成加载所以事件发生在其他工具中将是什么,但在人工交互的情况下,如舔按钮或其他东西。
在加载表单时克服事件尝试在formLoad中插入组合框的值,这样在加载这样的表单时会触发事件。
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Text = "aa"
End Sub
Through that the ComboBox will go to its event ComboBox1.SelectedIndexChanged
并在其上执行命令。
尝试在ComboBox事件上放置一个Break点来监视加载主窗体时是否发生事件...试试= D