pruebens Posted December 13, 2002 Posted December 13, 2002 Hello. Not sure where to post this. I've got a form that has a listbox that pulls it's data from a database and also has 10 empty textboxes on there as well. How do I make it so that when a user double clicks on one of the entries in the listbox it automatically moves what they double click over to the next empty textbox? Thanks. Quote
Moderators Robby Posted December 13, 2002 Moderators Posted December 13, 2002 here's a small sample... Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick If Not AddToTextbox(ListBox1.SelectedItem) Then MessageBox.Show("sorry all text boxes are full") End If End Sub Private Function AddToTextbox(ByVal txt As String) As Boolean Dim ctr As Control For Each ctr In Me.Controls If TypeOf ctr Is TextBox Then If ctr.Text.Length = 0 Then ctr.Text = txt Return True Exit Function End If End If Next Return False End Function Quote Visit...Bassic Software
pruebens Posted December 13, 2002 Author Posted December 13, 2002 you know that is twice now I think you've saved me Robby........thanks. Quote
Moderators Robby Posted December 13, 2002 Moderators Posted December 13, 2002 no problem... also, if you want to remove the clicked item once it's in the textbox... If Not AddToTextbox(ListBox1.SelectedItem) Then MessageBox.Show("sorry all text boxes are full") Else ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) End If Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.