Click here to Skip to main content
15,910,118 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
an anyone help me in my program

it goes like this:

i have an Listview And Listbox when i add item in my listview the enter button will also add the item in listview and will add also in listbox

for example: i enter Goerge into the listview and add button will automatically add the item Listview in ListBox so List view and ListBox will have the same Item..

the question is: if i remove the item selected in listview it will remove,but it didnt remove the same item in ListBox.. what are the code of my program?

please Help.. in VB.net
Posted
Comments
Sergey Alexandrovich Kryukov 9-Aug-13 21:49pm    
We don't know what's the code of your program; never saw it. Does it even exist? :-)
—SA
Member 10200452 9-Aug-13 21:59pm    
i respect Sir,,

For Each i As ListViewItem In LIST2.SelectedItems
LIST2.Items.Remove(i)
Next
Do While (ListBox1.SelectedItems.Count > 0)
ListBox1.Items.Remove(ListBox1.SelectedItem)
Loop
when i remove my selected listview Item it will Also remove in Listbox item
Sergey Alexandrovich Kryukov 9-Aug-13 22:21pm    
Very good, and where is the problem?
—SA
Member 10200452 9-Aug-13 22:27pm    
the problem is if the user select item on listview and i have a button delete and when the user click the delete button will delete the listview and also the listbox because the button add or enter is i set to add it to the listbox to have my summary of name..
Sergey Alexandrovich Kryukov 9-Aug-13 23:11pm    
???

1 solution

With this function:
Just change the LV to the name of your listbox
Then, to se if the list box contains an item with the specified text simply make the call

LVContains("Some String")


VB
''' <summary>
  ''' Cycles through each item in list view to compare the text property to the TXT
  ''' </summary>
  ''' <param name="TXT">The text to check for</param>
  ''' <returns>true if matching text is found in listview</returns>
  ''' <remarks></remarks>
  Private Function LVContainsText(TXT As String) As Boolean
      'prepare a result to return from the function
      'setting it to false by default to simplify this process
      Dim result As Boolean = False

      'cycle through the list of items in listView in order to check it's properties
      'idividual of each other
      For Each I As ListViewItem In LV.Items
          'test to see it the text property matches
          If I.Text = TXT Then
              'if it does match then it's already in the list
              result = True
          End If
      Next

      'return the result
      Return result
  End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900