I've use a for...each loop to move items in a listview
upwards, and now i want to write a routine to move items
down.
For this, i need to do a for...each starting with the
last item in the list and ending with the first.
Any ideas on how to do this? 8 1407
I tried for ages before posting, and almost as soon as
i'd posted i sorted it. Isn't that always the way?
Instead of a for...each i used a for...next with a step
of -1. What was throwing me was how to use the
for...next variable with the listview, which i did with:
Dim lvi As ListViewItem = ListView1.Items.Item(variable)
Instead of "for each lvi in listview1.items"
If there's a way of doing this with for...each, i'd still
like to know, as i'm learning at the mo'.
You could use a For-Next for that:
For i As Integer = ListView1.Items.Count - 1 To 0 Step -1
Dim li As ListViewItem = ListView1.Items(i)
'Do stuff...
Next
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Colmag" <an*******@discussions.microsoft.com> schreef in bericht
news:01****************************@phx.gbl... I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this?
Jan,
Thanks for the info. You must have posted while the
server was sorting my own reply!
It's great to hear a solution that matches my own, good
for the confidence! -----Original Message----- You could use a For-Next for that:
For i As Integer = ListView1.Items.Count - 1 To 0 Step -1 Dim li As ListViewItem = ListView1.Items(i) 'Do stuff... Next
-- Greetz, Jan __________________________________ Read my weblog: http://weblogs.asp.net/jan "Colmag" <an*******@discussions.microsoft.com> schreef
in berichtnews:01****************************@phx.gbl... I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move
items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this?
.
"Colmag" <an*******@discussions.microsoft.com> schrieb I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this?
Can not be done with for-each. Use
For index = lastIndex to firstindex step -1
instead.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Thanks. Confirmation of what can't be done is just as
useful as knowing what can (saves me wasting time!) -----Original Message----- "Colmag" <an*******@discussions.microsoft.com> schrieb I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move
items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this?
Can not be done with for-each. Use For index = lastIndex to firstindex step -1 instead.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
Are you just trying to sort?
Can you be a little more specific?
is this what you want?
Private Sub MoveDown()
Dim lvi As ListViewItem
For Counter As Integer = (Me.ListView1.Items.Count - 1) To 0 Step -1
lvi = Me.ListView1.Items(Counter)
'do something here
Next
lvi = Nothing
End Sub
"Colmag" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this?
* "Colmag" <an*******@discussions.microsoft.com> scripsit: I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
\\\
Dim i As Integer
For i = Me.ListView1.Items.Count - 1 To 0 Step -1
Me.ListView1.Items(i).Text = "Foo"
Next i
///
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Thanks to everyone for the great replies. I managed to
sort it about a minute after posting (typical...), but
posted as anonymous by accident. I used a for...next
with a step of -1. As i'm learning at the mo', I was
interested to know if it's possible with a for...each,
but it seems not.
Jared, i'm using the routine to reorder items in a
listview. I can select multiple objects, then click on
up/down buttons to move the items up and down the list. -----Original Message----- I've use a for...each loop to move items in a listview upwards, and now i want to write a routine to move items down.
For this, i need to do a for...each starting with the last item in the list and ending with the first.
Any ideas on how to do this? . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jean-Christophe Michel |
last post by:
Hi,
I have a stylesheet with an accumulator like this
<xsl:param name="new-x">
<xsl:for-each select="anode">
<mynode>
<xsl:attribute name="attr">
<xsl:value select="anode/atag" />...
|
by: matatu |
last post by:
Hi to everybody,
It's possible to exit from a cycle for-each?
I have this code:
1: <xsl:for-each select="field">
2: <xsl:variable name="tagfield" select="@tag"/>
3: <xsl:variable...
|
by: Floris van Haaster |
last post by:
Hi All!
I have a question, i have a web application and I store some member
information in a variable i declared in a module like:
Public some_info_variable as string
in module1.vb
But...
|
by: tshad |
last post by:
Is there a way to run a script or function on entry of each page without
having to put a call in each page?
Periodically, I find something I want to do each time a page is entered and
I have to...
|
by: Michael D. Ober |
last post by:
In VB 6, the loop iterator v in the following code must be a variant.
dim v as variant
dim c as new collection
for each v in collection
...
next v
What is the general translation in VB 7.1...
|
by: Neal |
last post by:
Hi All,
I used an article on XSLT and XML and creating a TOC written on the MSDN
CodeCorner.
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dncodecorn/html/corner042699.htm
However, it did'nt...
|
by: xmlhelp |
last post by:
stuff.XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="uid"/>
<xsl:template match="/">
parameter...
|
by: The Frog |
last post by:
Hello everyone,
I am working on an application that can build database objects in MS
Access from text files. I suppose you could call it a backup and
restore type routine.
Accessing the...
|
by: ADezii |
last post by:
If you want to visit each item in an Array, you have two alternatives:
Use a For Each..Next loop, using a Variant to retrieve each value in turn.
Use a For...Next loop, looping from the Lower...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |