PC Review


Reply
Thread Tools Rate Thread

How do I sort a listview control

 
 
James L
Guest
Posts: n/a
 
      6th Jun 2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleCBZYWtobmluIFtNVlBd?=
Guest
Posts: n/a
 
      6th Jun 2005
http://blog.opennetcf.org/ayakhnin/P...6-4ee695a644d1

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org


"James L" wrote:

> 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
>
>

 
Reply With Quote
 
Joćo Paulo Figueira [eMVP]
Guest
Posts: n/a
 
      6th Jun 2005
Here is another alternative:
http://www.codeproject.com/netcf/Net...rtListView.asp

--
Joćo Paulo Figueira
Embedded MVP
http://nativemobile.blogspot.com/

"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
>



 
Reply With Quote
 
JamesL
Guest
Posts: n/a
 
      7th Jun 2005
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
>



 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      15th Jun 2005
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
>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net ListView control - Configure ListView option missing? . Microsoft ASP .NET 0 24th Jul 2010 01:20 AM
ListView sort Alan T Microsoft C# .NET 11 13th Sep 2006 03:24 PM
How to Sort in ListView =?Utf-8?B?VmVua2F0YXJhamFu?= Microsoft VB .NET 1 15th Jul 2004 12:09 PM
ListView control ignores rearranged column order on sort. Frank Rizzo Microsoft VB .NET 0 3rd May 2004 07:47 PM
Sort ListView zZ Microsoft Dot NET 1 22nd Oct 2003 10:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:46 PM.