Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Moderators
Posted

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

Visit...Bassic Software
  • Moderators
Posted

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

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...