Solved

Listview

Posted on 1998-08-17
9
362 Views
Last Modified: 2010-07-27
How can I set the last ListIndex and show selected row in a Listview after updating?  I know the selected index before updating the listview. But I'm not able to set the index after updating.
0
Comment
Question by:test031097
  • 3
  • 3
  • 3
9 Comments
 
LVL 2

Expert Comment

by:cantrell
ID: 1429440
List1.Selected(1) = True

Replace "List1" with your listbox name, and the "(1)" with the index number of the last item in your listbox.
0
 
LVL 2

Expert Comment

by:cantrell
ID: 1429441
Dim trythis As Integer

trythis = List1.ListCount

List1.Selected(trythis - 1) = True


0
 
LVL 2

Expert Comment

by:cantrell
ID: 1429442
Sorry, I hit "submit" first without re-reading your question, but the above should be the answer.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:test031097
ID: 1429443
Thanks for your answer, cantrell. But I don't mean a listbox. I mean a LISTVIEW.
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1429444
dim liItem as listitem

set liitem = lvw.selecteditem

'do updating here

set lvw.selecteditem = lvw.listitems(liitem.index)

0
 

Author Comment

by:test031097
ID: 1429445
Thanks, anthonyc,
this is your propose:

dim liItem as listitem
    set liitem = lvw.selecteditem
    'do updating here

**************
After updating I have to clear the listItems, because I reload the Listview.
The members from iitem (also index) were be deleted by clear listItems.
****************
    set lvw.selecteditem = lvw.listitems(liitem.index)  **** <- it is deleted ********
0
 
LVL 6

Accepted Solution

by:
anthonyc earned 100 total points
ID: 1429446
well you said updating, NOT deleting.  

Are you using the KEY property?  Save that in a variable before the deleting, then

set lvw.selecteditem = lvw.listitems(szSavedKey)
0
 

Author Comment

by:test031097
ID: 1429447
Thanks, anthonyc. I saved the key in a variable. With help this variable I was able to find the Itemindex.

strKey = LstVwStammdaten.SelectedItem

**************
Delete

*************
For i = 1 To LstVwStammdaten.ListItems.Count
    If "'" & strKey & "'" = LstVwStammdaten.ListItems(i).Key Then
      Exit For
    End If
  Next i
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1429448
ewww.... That code is UGLY!

If you want to find the item index just do this:

dim nIndex as integer
on local error resume next
nIndex = lstVwStammdaten.Listitems(strKey).Index
if nIndex = 0 then msgbox "This item is not in the list!"

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 101
Error when passing an argument to a vb6 that contains  '/' 7 46
Problem to line 23 74
VB script to continue despite error 2 51
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question