如何第二次禁用文本框? 这是我的代码,在表单加载中,文本框被禁用,除非用户将输入数据库中的idnumber。但是如果用户输入数据库中的idnumber然后输入另一个不是的数字,该怎么办呢? 这就是这段代码的用武之地,但它存在问题,在点击鼠标时它不会禁用文本框,这样做的正确方法是什么?
Private Sub Button12_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button12.MouseClick
Dim NoAcc As String
Dim NoAccmod2 As String
Dim NoPas As String
Dim sqlcon As New MySqlConnection("Server=localhost; Database=school;Uid=root;Pwd=nitoryolai123$%^;")
Dim sqlcom As MySqlCommand = New MySqlCommand("Select * from student where IDNO= '" & TextBox14.Text & "' ", sqlcon)
sqlcon.Open()
Dim rdr As MySqlDataReader
rdr = sqlcom.ExecuteReader
If rdr.HasRows Then
rdr.Read()
NoAcc = rdr("IDNO")
If (TextBox14.Text <> NoAcc) Then
MsgBox("ID Number is not yet registered!, please register first in the general information before trying to register parents information", MsgBoxStyle.Information)
TextBox7.Enabled = False
TextBox8.Enabled = False
TextBox9.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
TextBox12.Enabled = False
TextBox13.Enabled = False
End If
End If
答案 0 :(得分:1)
在例程的顶部总是禁用文本框,然后在ID NUMBER匹配时启用它们。
根据您实际尝试在此处实现的内容,也可以在鼠标单击中清除感兴趣的文本框(如果ID匹配)或将其设置为FOCUS(如果不匹配)(以允许他们查看内容)他们进入并做出改变......也许他们错了?)