Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ListView Question

1 view
Skip to first unread message

Joe Fallon

unread,
Dec 2, 2003, 2:04:57 PM12/2/03
to
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?
--
Joe Fallon


Herfried K. Wagner [MVP]

unread,
Dec 2, 2003, 2:15:23 PM12/2/03
to

Joe Fallon

unread,
Dec 2, 2003, 2:25:33 PM12/2/03
to
LOL!

I don't speak C++.

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


"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:bqiok2$233s2t$3...@ID-208219.news.uni-berlin.de...

Herfried K. Wagner [MVP]

unread,
Dec 2, 2003, 3:05:44 PM12/2/03
to
* "Joe Fallon" <jfal...@nospamtwcny.rr.com> scripsit:
> I don't speak C++.
>
> I guess you are saying there is no VB.Net way to do this.

There is a VB.NET way, by using p/invoke. You will find a VB6 sample
here, sorry, I don't have a .NET implementation:

<http://www.mvps.org/vbnet/code/comctl/lvheaderimage.htm>

One Handed Man [ OHM ]

unread,
Dec 2, 2003, 3:14:10 PM12/2/03
to
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 Fallon wrote:
> LOL!
>
> I don't speak C++.
>
> I guess you are saying there is no VB.Net way to do this.
>

> "Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
> news:bqiok2$233s2t$3...@ID-208219.news.uni-berlin.de...
>> * "Joe Fallon" <jfal...@nospamtwcny.rr.com> scripsit:
>>> 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/groups?selm=erqckvkiopu68885nek3i60674c1un04bl%404
> ax.com>
>>
>> --
>> Herfried K. Wagner [MVP]
>> <http://www.mvps.org/dotnet>

Best Regards - OHMBest Regards - OHM OneHan...@BTInternet.Com


Joe Fallon

unread,
Dec 2, 2003, 3:22:28 PM12/2/03
to
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


--
Joe Fallon


"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message

news:bqirkf$23cfbb$5...@ID-208219.news.uni-berlin.de...

Herfried K. Wagner [MVP]

unread,
Dec 2, 2003, 5:15:49 PM12/2/03
to
* "Joe Fallon" <jfal...@nospamtwcny.rr.com> scripsit:
> 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.

0 new messages