• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Listview auto-insert to Row


I need the following to occur, but am having difficulty making it happen.

I have a Listview set up with multiple Rows and 2 Columns. A name is entered into the first Column by the user.

If the Listview Count = 1 only, I need the second Column to auto-update with the word 'Default'.
I have tried SendKeys to get the focus into the first Row, but this doesn't always work. Can someone please suggest a better way.

Thank you.


1 Solution
Ryan ChongCommented:
Hi, use listview1.listitems(i).selected = true; i = listview.listitems.index

Private Sub ListView1_AfterLabelEdit(Cancel As Integer, NewString As String)
    If ListView1.ListItems.Count = 1 Then
        ListView1.ListItems(1).SubItems(1) = "Default"
    End If
End Sub

Is all you need, this detects that the column label has changed, and if there is only one item then the second column is set to "Default", nothing happens if there is more than one row.
tvtechAuthor Commented:
Thanks very much for the response. Much appreciated.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now