Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. remove item without being selected only with the name

remove item without being selected only with the name

Scheduled Pinned Locked Moved Visual Basic
help
2 Posts 2 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Benjamindh
    wrote on last edited by
    #1

    Hello everyone, I comment I have the following problem. It happens that I have this code where the information sent from a TCP is added, but I can't find a way to make it so that if a user leaves the application, it is removed from the listviem without having to be selected. only with the username that is in column 1

    Protected Sub ActualizarTextoMensaje(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim HHusuario As String = "config\usuario.txt"
    Dim Usuario As String
    Usuario = System.IO.File.ReadAllText(HHusuario)
    Dim line As String = ContenidoMensaje
    Dim parts() As String = line.Split("|"c)
    'ahora decodifico los bytes y los paso a el ListView
    Dim item As New ListViewItem()
    item.Text = parts(0)
    If item.Text = Usuario Then
    LNetgames.Items.Remove(item)
    Else
    For i As Integer = 1 To parts.Length - 1
    item.SubItems.Add(parts(i))
    Next
    LNetgames.Items.Add(item)
    End If

    End Sub
    
    V 1 Reply Last reply
    0
    • B Benjamindh

      Hello everyone, I comment I have the following problem. It happens that I have this code where the information sent from a TCP is added, but I can't find a way to make it so that if a user leaves the application, it is removed from the listviem without having to be selected. only with the username that is in column 1

      Protected Sub ActualizarTextoMensaje(ByVal sender As Object, ByVal e As System.EventArgs)
      Dim HHusuario As String = "config\usuario.txt"
      Dim Usuario As String
      Usuario = System.IO.File.ReadAllText(HHusuario)
      Dim line As String = ContenidoMensaje
      Dim parts() As String = line.Split("|"c)
      'ahora decodifico los bytes y los paso a el ListView
      Dim item As New ListViewItem()
      item.Text = parts(0)
      If item.Text = Usuario Then
      LNetgames.Items.Remove(item)
      Else
      For i As Integer = 1 To parts.Length - 1
      item.SubItems.Add(parts(i))
      Next
      LNetgames.Items.Add(item)
      End If

      End Sub
      
      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      You should then first Find an item having the text of "username" in column 1. Then if it was found delete the item with the found item index. Note that there could be more than one item in your listview!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups