ListView Question

J

Joe Fallon

The ListView control is the one used in Windows Explorer Detail view.
When you click a column heading in Windows Explorer to sort the column you
get a little triangle pointing up or down depending on the sort direction.

How do you get the triangle to appear when you click a column heading on a
ListView control in VB.Net?
 
H

Herfried K. Wagner [MVP]

* "Joe Fallon said:
The ListView control is the one used in Windows Explorer Detail view.
When you click a column heading in Windows Explorer to sort the column you
get a little triangle pointing up or down depending on the sort direction.

How do you get the triangle to appear when you click a column heading on a
ListView control in VB.Net?

<http://groups.google.com/[email protected]>
 
J

Joe Fallon

LOL!

I don't speak C++.

I guess you are saying there is no VB.Net way to do this.
 
O

One Handed Man [ OHM ]

have you ever been convicted ?, if so this would make you a 'Convicted
Fallon' and anything that you write which could be said to be typical of you
would mean that you had commited a 'Fallony'

Sorry , could not resist that :)

Regards - OHM


Joe said:
LOL!

I don't speak C++.

I guess you are saying there is no VB.Net way to do this.


<http://groups.google.com/groups?selm=erqckvkiopu68885nek3i60674c1un04bl@4

Best Regards - OHMBest Regards - OHM (e-mail address removed)
 
J

Joe Fallon

Herfried,
The rest of the thread you pointed me to did include a VB.Net solution from
Jay Harlow.
I just implemented it and it works great.

The trick is to change the column text value when sorting by adding 3 spaces
and the Unicode characters for the small black Up and Down triangles. Strip
them off when changing columns.

Sample code for lurkers:
Protected Overrides Sub dvDisplay_ColumnClick(ByVal sender As Object, ByVal
e As System.Windows.Forms.ColumnClickEventArgs)

'remove sort icon from old column.

If SortColumn <> -1 Then

lv.Columns.Item(SortColumn).Text =
lv.Columns.Item(SortColumn).Text.TrimEnd(Chr(32), Chr(32), Chr(32),
ChrW(&H25B2), ChrW(&H25BC))

End If

If e.Column <> SortColumn Then

SortColumn = e.Column

mSortDirection = "ASC"

'add down icon

lv.Columns.Item(SortColumn).Text &= " " & ChrW(&H25B2)

Else

If mSortDirection = "ASC" Then

mSortDirection = "DESC"

'do the sort

'add down icon

lv.Columns.Item(SortColumn).Text &= " " & ChrW(&H25BC)

Else

mSortDirection = "ASC"

'do the sort

'add up icon

lv.Columns.Item(SortColumn).Text &= " " & ChrW(&H25B2)

End If

End If

End Sub
 
H

Herfried K. Wagner [MVP]

* "Joe Fallon said:
The rest of the thread you pointed me to did include a VB.Net solution from
Jay Harlow.
I just implemented it and it works great.

The trick is to change the column text value when sorting by adding 3 spaces
and the Unicode characters for the small black Up and Down triangles. Strip
them off when changing columns.

ACK, that will work. Nevertheless it doesn't mimic the nice 3D effect
like in explorer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top