473,396 Members | 1,799 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,396 software developers and data experts.

Listview Sorting Graphic in Column Header...

I have successfully integrated sorting in the listview control with the
following code:

Private Sub ListView_ColumnClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.ColumnClickEventArgs) Handles ListView.ColumnClick

If ListView.Sorting = System.Windows.Forms.SortOrder.Ascending Then
ListView.Sorting = System.Windows.Forms.SortOrder.Descending
Else
ListView.Sorting = System.Windows.Forms.SortOrder.Ascending
End If

Dim sorter As New SortOrder(e.Column)
ListView.ListViewItemSorter = sorter

End Sub

Private Class SortOrder
Implements IComparer
Dim Column As Integer

Public Sub New(ByVal aColumn As Integer)
Column = aColumn
End Sub

Public Function compare(ByVal x As Object, ByVal y As Object) As
Integer Implements IComparer.Compare
Dim xItem, yItem As System.Windows.Forms.ListViewItem

xItem = CType(x, ListViewItem)
yItem = CType(y, ListViewItem)

If xItem.ListView.Sorting =
System.Windows.Forms.SortOrder.Ascending Then
Return
(xItem.SubItems(Column).Text).CompareTo(yItem.SubI tems(Column).Text)
Else
Return
(yItem.SubItems(Column).Text).CompareTo(xItem.SubI tems(Column).Text)
End If
End Function
End Class

But I would like to easily add an up and down arrow when the column is
clicked. I am lousy with graphics so I don't know if this code can be
easily modified to handle this enhancement. A point in the right direction
would be greatly appreciated.
Jul 21 '05 #1
0 1716

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

Similar topics

0
by: Abhishek | last post by:
Hi! I am using listview control having 4 columns. I want it to behave in a similar manner as the details view of windows explorer. i.e it should sort on all the columns and all the columns...
0
by: Abhishek | last post by:
Hi! I am using listview control containing 4 columns. I want it to behave in a similar manner as the details view of windows explorer. i.e it should sort on all the columns and all the columns...
6
by: ReMEn | last post by:
My question is this: How can I apply some kind of a function to a listview that allows it to sort by both string and numbers whenever a header is clicked? For example: -------------------...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
1
by: rmorvay | last post by:
I have successfully integrated sorting in the listview control with the following code: Private Sub ListView_ColumnClick(ByVal sender As Object, ByVal e As...
2
by: Li Pang | last post by:
Hi, I used some code to add an arrow icon onto a listview header column for the sorting purpose. However, after the icon added, the TextAlign of the column becomes "left", if I enforced...
2
by: jediknight | last post by:
Hi, I have a listview which has columns of text and columns of numerical data. I need to be able to sort these columns into ascending/desending order whenever the user clicks on the column...
11
by: Alan T | last post by:
Does the ListView supports sort? I want to have a up/down arrow/triangle that show it is sorted asc or desc on the column headers when I click the column header. May be I need a third-party...
3
by: --== Alain ==-- | last post by:
Hi, I have some little issue when i want to redraw the columnHeader of my ListView. Basically i display a little arrow to show the sortOrder of each column. For sure only the clicked column is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
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,...
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.