How do you get the triangle to appear when you click a column heading on a
ListView control in VB.Net?
--
Joe Fallon
<http://groups.google.com/groups?selm=erqckvkiopu68885nek3i60674c1un04bl%404ax.com>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
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...
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>
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
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...
ACK, that will work. Nevertheless it doesn't mimic the nice 3D effect
like in explorer.