473,498 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Nov 20 '05 #1
1 1530
* "rmorvay" <ad*************@hotmail.com> scripsit:
[...]

I replied in the Windows Forms group. Please do not multipost.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

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

Similar topics

0
1726
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...
0
1206
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
1123
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
1519
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
25422
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...
2
4938
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...
0
1610
by: p19010101 | last post by:
Using sample codes from msdn and code snippets from this group, I am able to derive a custom listivew user control with column sorting and up/down icons in the column header. It works fine except...
2
7203
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
9970
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
2243
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
7005
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...
0
7168
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
7210
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...
1
6891
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
7381
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
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.