Re: Listview subitem sorting..

From: Vas (anonymous_at_discussions.microsoft.com)
Date: 03/15/04


Date: Sun, 14 Mar 2004 16:51:08 -0800

Use Parse to change the string

long a = long.Parse(((ListViewItem)x).SubItems[col].Text);
long b = long.Parse(((ListViewItem)y).SubItems[col].Text);

and use a conditional statement

(a < b) ? -1 : ((a > b) ? 1 : 0);

If you multiply the result of any of the tests by -1 you can sort ascending/descending.

Also test for white spaces, return 1 for x and -1 for y to keep the spaces down and out the way, I think.



Relevant Pages

  • Re: How can i Right Trim all the spaces of a very long (2000 chars) Charecter string ?
    ... > Right Trim Function in c,using Binary search kind of fast algorithm? ... > Start from the right most charecter of the string to the left of the ... Is the string allowed to contain white spaces in the significant part? ...
    (comp.lang.c)
  • Re: VB help
    ... retrieving the a srting value in the database through a record ... retrieved string shows some junk charecters in place of white spaces ... string in the database 8a Church Road Barry ...
    (microsoft.public.vb.general.discussion)
  • Re: Regex for white space
    ... > Suppose a series of white spaces in between a string, ... > Now I wonder how can I get a new string contains no spaces or substuted by symbols like _ ... Lew Pitcher, IT Specialist, Enterprise Data Systems ...
    (comp.unix.shell)
  • Re: Regex for white space
    ... Ying Zu wrote: ... > Suppose a series of white spaces in between a string, ... > Now I wonder how can I get a new string contains no spaces or substuted by symbols like _ ... BashDiff: Super Bash shell ...
    (comp.unix.shell)
  • Re: Is there any function as Trim in Jscript/JavaScript?
    ... > Is there any function as Trim in Jscript/JavaScript? ... > not find anything untill now. ... > a string with some or a lot of white spaces. ...
    (microsoft.public.scripting.jscript)