Results 1 to 4 of 4

Thread: Sorting listview

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    Sorting listview

    I have a listview that has multiple columns. I am wanting to sort these columns when clicking on the column header.

    I see there is a sort function, but am not having much luck in using it.

    How can i sort my listview when clicking on the column header?

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Sorting listview

    Simon, Have you seen this msdn link?

    Topic: ListView.ColumnClick Event
    Link: http://msdn.microsoft.com/en-us/libr...lumnclick.aspx

    Or this?

    Topic: How to sort a ListView control by a column in Visual Basic .NET or in Visual Basic 2005
    Link: http://support.microsoft.com/kb/319399
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    Re: Sorting listview

    The second link works very well. One thing however, if one of my columns is an integer or a long, how can I easily modify the code to sort by the value of the number, and not just its first character?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    Re: Sorting listview

    Another thing... I am not sure why, but when I click on my 5th column, I get the following error:

    InvalidArgument=Value of '5' is not valid for 'index'.
    Parameter name: index
    I do not know why this happens... it is the exact code from the MSDN site. I have not had any problems with this before.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width