Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>your code does not show where, when or how you try to remove the subitems. Based on the Title, I'm guessing that the LVI is already assigned to the ListView, so doing stuff to TempNode might not do anything (it could be a different LVI by this time.)</p> <p><code>ListViewItem.SubItems.Clear()</code> is the correct syntax but this will also remove the <code>Item.Label</code> So:</p> <pre><code> ' preserve "Label" and put it back: Dim txt As String = LV.SelectedItems(0).Text LV.SelectedItems(0).SubItems.Clear() LV.SelectedItems(0).Text = txt </code></pre> <p>or reference as <code>LV.Items(IndexOfTheItemToClear).Text</code></p> <p>another way:</p> <pre><code> ' loop BACKWARDS to remove all but the last subitem (index = 0) For n As Integer = LV.SelectedItems(0).SubItems.Count - 1 To 1 Step -1 LV.SelectedItems(0).SubItems.RemoveAt(n) Next </code></pre> <p>since you are removing things from the collection you are looping on, you have to loop backwards otherwise your code runs out of items before <code>N</code> is reached.</p> <p>EDIT</p> <p>Your question is not nearly as clear as you might think it is. If you are trying to remove the Item represented by TempNode in the code, you have to find it and remove it. Once TempNode has been added to the LV, you cannot recreate TempNode (<code>TempNode = New ListViewItem(TempStr)</code>) because NEW makes a <strong>new</strong> ListViewItem which is not the same as the one you added earlier. So, you need to find the old one and remove it (not the same as <code>clear[ing] the entire listview</code> or <code>flush all data from tempnode</code>. So:</p> <pre><code>' presumably 'pendrun.Rows(pop)("RID")' is the item text, so find it: Dim search As String = pendrun.Rows(pop)("RID") For n as integer = 0 to LV.Items.Count - 1 if LV.Items(n).Text = search then LV.Items.RemoveAt(n) Exit For End iF Next n </code></pre> <p>It wont clear the LV but will find a specific item and remove it and the associated ListViewItem.SubItems from the LV. Matching on Text is pretty weak, so if you have something more unique like an ID, you can store that as a subitem and search that way:</p> <pre><code> if LV.Items(n).SubItems(WhereYouPutIt).Text = search then... </code></pre> <p>or even stash it in the <code>ListViewItem.Tag</code> property:</p> <pre><code>if LV.Items(n).Tag = search then... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload