473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

swapping two listview lines

Hi,

A trivial question:

Is there an easier/more elegant way of swapping two lines in a 5-column
listview control than the "primitive" method indicated below?

Dim tmp0 As String
Dim tmp1 As String
Dim tmp2 As String
Dim tmp3 As String
Dim tmp4 As String

tmp0 = lvwMain.ListItems.Item(selNum).Text
tmp1 = lvwMain.ListItems.Item(selNum).ListSubItems(1).Tex t
tmp2 = lvwMain.ListItems.Item(selNum).ListSubItems(2).Tex t
tmp4 = lvwMain.ListItems.Item(selNum).ListSubItems(3).Tex t
tmp5 = lvwMain.ListItems.Item(selNum).ListSubItems(4).Tex t

lvwMain.ListItems.Item(selNum).Text =
EditPage.lvwMain.ListItems.Item(selNum - 1).Text
lvwMain.ListItems.Item(selNum).ListSubItems(1).Tex t =
lvwMain.ListItems.Item(selNum - 1).ListSubItems(1).Text
lvwMain.ListItems.Item(selNum).ListSubItems(2).Tex t =
lvwMain.ListItems.Item(selNum - 1).ListSubItems(2).Text
lvwMain.ListItems.Item(selNum).ListSubItems(3).Tex t =
lvwMain.ListItems.Item(selNum - 1).ListSubItems(3).Text
lvwMain.ListItems.Item(selNum).ListSubItems(4).Tex t =
lvwMain.ListItems.Item(selNum - 1).ListSubItems(4).Text

lvwMain.ListItems.Item(selNum - 1).Text = tmp0
lvwMain.ListItems.Item(selNum - 1).ListSubItems(1).Text = tmp1
lvwMain.ListItems.Item(selNum - 1).ListSubItems(2).Text = tmp2
lvwMain.ListItems.Item(selNum - 1).ListSubItems(3).Text = tmp3
lvwMain.ListItems.Item(selNum - 1).ListSubItems(4).Text = tmp4

Soeren W.
Aug 3 '05 #1
0 3043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
3
by: Wim | last post by:
I'm trying to add files with a OpenFileDialog to a listview. This is what I've come up with sofar: protected void ButAddClick(object sender, System.EventArgs e) { OpenFileDialog MyDialog = new...
0
by: willow1480 | last post by:
I am developing a small little Service Control Application. I am using a listview control with checkboxes and getting the list of services I want to control from a text file. When you check a...
1
by: Andrew S. Giles | last post by:
I am trying to provide a list to the user. This list is the 1st 25 lines of a given file. I want to provide the line number to the user, before each line. I see when I add Columns to a...
9
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to...
3
by: larry mckay | last post by:
anyone have the code to select and listview item or row (subitems) after a doubleclick event from a listview. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
1
by: Paja via .NET 247 | last post by:
Hi all, I've got problem with ListView in VB.NET. I want to colorlines (odd and even with different colors - gray and white). I'musing item.backcolor property which works fine, but... If Iclick on...
2
by: Sin Jeong-hun | last post by:
Is it possible to get current visible rect when there is a scrollbar on the ListBox? Say, if the ListBox is in Details mode, and there are 1000 lines. The user has scrolled down to 500th line...
2
by: milindsm | last post by:
Hello, I am working on a task in which I have to read line by line from a text file and add it to listview as an item. Since the file is too large (around 10K-15K lines), it was taking hell lot...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.