Assuming lvwItemList is a ListView, Me.lvwItemList.Columns(e.Column) returns
a ColumnHeader - not ColHeader.
Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"JamesL" <(E-Mail Removed)> wrote in message
news:JW8pe.396$(E-Mail Removed)...
> OK
> I checked the archives and from there I read the quickstart tutorial. I
> duplicated the code from the tutorial, thinking I understood it fairly
> well, and modified as necessary such as changing the name of the listview
> control to the name I used for my listview control.
>
> On the following line:
> Dim clickedCol As ColHeader = CType(Me.lvwItemList.Columns(e.Column),
> ColHeader)
>
> I get this error:
>
> An unhandled exception of type 'System.InvalidCastException' occurred in
> testprogram.exe
>
> What the heck does that mean?
>
>
>
> ColHeader is defined with the following code:
>
> Public Class ColHeader
>
> Inherits ColumnHeader
>
> Public ascending As Boolean
>
> Public Sub New(ByVal [text] As String, ByVal width As Integer,
> ByVal align As HorizontalAlignment, ByVal asc As Boolean)
>
> Me.Text = [text]
>
> Me.Width = width
>
> Me.TextAlign = align
>
> Me.ascending = asc
>
> End Sub
>
> End Class
>
>
>
> James
>
> "James L" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>I am trying to sort a listview control by subitem in ascending and
>> descending order. I followed the instructions in the Visual Studio
>> help. They are very explicit and detailed, but unfortuntely it does
>> not work. Is the help applicable to VB.NET compactframework or only to
>> desktop VB.NET?
>>
>> First:
>>
>> The help says to "add the following line to the forms constructor":
>>
>> Addhandler listview.columnclick address of me.listview_columnclick
>>
>> I am unlcear where I am supposed to place this line. If I place it in
>> the ColumnClick event of the listview it shows no errors but is that
>> the correct place? Does it belong in the columnclick event, or
>> elsewhere?
>>
>> Second:
>> In the code window VisualStudio underlines certain items and gives me
>> error warnings with them. Those warnings are:
>>
>> me.listview.sorting.....
>> 'Sorting' is not a member of 'System.windows.forms.listview'
>>
>> sortorder.ascending
>> Name SortOrder is not declared
>>
>> me.listview.sort.....
>> 'Sort' is not a member of 'System.windows.forms.listview'
>>
>> me.listview.ListViewItemSorter.....
>> ListViewItemSorter is not a member 'System.windows.forms.listview'
>>
>> I understand what the errors mean, these properties do not exist for
>> the listview control. But if they do not exist, why does the help tell
>> me to use them? Is there another system item I should be importing
>> that I might have missed in the Imports lines? Currently I have:
>>
>> Imports System
>> Imports System.io
>> Imports System.Reflection
>>
>>
>> James Lysaght
>>
>
>