Results 1 to 2 of 2

Thread: overwrite item

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    5

    Arrow overwrite item

    Hi there
    How can I search a listbox with the selected item from a combobox, and if it was found to already exist in the listbox to overwrite the item with out making a new line in the listbox

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted
    2.         If ComboBox1.SelectedItem Is Nothing Then Exit Sub
    3.         If Not ListBox1.Items.Contains(ComboBox1.SelectedItem) Then
    4.             ListBox1.Items.Add(ComboBox1.SelectedItem)
    5.         End If
    6.     End Sub

    If it exists then there is no need to overwrite it since it is the same. If you mean that only one part matches then you'll have to give more information about what you are using as items, otherwise the above should work.

    Actually I just reread your post and what I posted is a little bit different. It will add the combo.SelectedItem to the listbox if it does NOT exist in the listbox already.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width