Dreamweaver,表单中有个列表框和一个文本域,怎样让文本域的内容和列表框的内容关联起来??

2024-11-17 11:35:01
推荐回答(2个)
回答(1):

Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar.ToString() = Chr(13) Then
Dim str As String = TextBox1.Text
If Not ListBox1.Items.Contains(str) Then
ListBox1.Items.Add(str)
End If
End If
End Sub

Private Sub btn_Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedIndex > 0 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
End Sub

Private Sub btn_Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
End Sub

回答(2):

通过JS或JQUERY来实现