Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

I have noticed that Listview does not have a replace option, so...

How can one replace a value in the last row, 10th column in a listview with a new value?

 

Thanks

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

Dim itmX As ListViewItem
' Get the last item into itmX
itmX = ListView1.Items(ListView1.Items.Count - 1)
' Change column 10s text
itmX.SubItems(9).Text = "My replaced text"
' Put back into listview as last item
ListView1.Items(ListView1.Items.Count - 1) = itmX

 

Hope this helps

 

Andy

Code today gone tomorrow!
  • *Experts*
Posted (edited)

Thanks Andy,

 

Your code works fantastic!!!

 

I did notice that it did produce some screen flicker though.

Is there a way to postpone the screen refresh until the listview line is replaced? (or maybe its my old Video card)

 

Thanks

Edited by DiverDan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

No its not flicker you can make it so no screen flick doesn't happen by the following code....

 

       Dim itmX As ListViewItem
       ListView1.BeginUpdate()
       itmX = ListView1.Items(ListView1.Items.Count - 1)
       itmX.SubItems(9).Text = "BLUE"
       ListView1.Items(ListView1.Items.Count - 1) = itmX
       ListView1.EndUpdate()

 

give that a go

 

Andy

Code today gone tomorrow!
  • *Experts*
Posted

If it is possible, I have one more listview question.

 

I'd like to save the listview contents into a serialized array each time it is updated. Then, if needed through the mnuUndo, pop it back into the listview by deserializing the array with your update method...

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins 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...