Results 1 to 13 of 13

Thread: [RESOLVED] Invisible columns in a ListView

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Invisible columns in a ListView

    If I want to create an invisible column in a listview, do I set its width to 0 or is there a more convenient way to do it?
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Invisible columns in a ListView

    To my knowledge, that is the only way other.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Invisible columns in a ListView

    Its is the easiest way, setting width to zero, unless you wanted to subclass the listview and possibly cancel out the drawing of the column.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Invisible columns in a ListView

    Yes, which was what I was referring to with subclassing the listview. Not I made a revision to his code in post #14 to support the double click autoresizing of the columns.

    Its a bit of work but if the data is being hidden for astechic reasons and not as a security method then setting the column width to zero is allot easier and not overkill for that use.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Invisible columns in a ListView

    Quote Originally Posted by RhinoBull
    Since columns can still be resized you may want to look at this nice sample by Aaron Young:

    Preventing certain Listview columns from sizing
    Now I've just remembered I'd seen this thread some time ago but had completely forgotten about it.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  7. #7
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: [RESOLVED] Invisible columns in a ListView

    Honestly I don't understand why would you want to create a hidden column in the ListView. I simply just use a class where I store the extra data, and tie the two using a key. Also, you can add extra data in the item's Tag property.

    And if you want to use the extra column for the purpose of sorting, then why not just sort the data before you add the data in the ListView ? If you get the data from a database, this is really easy by just modifying the SELECT query, and add an ORDER BY...

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Invisible columns in a ListView

    Because by setting a flag you can display a columns data depending on the users level of permissions. No extra work switching between the two.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] Invisible columns in a ListView

    Quote Originally Posted by CVMichael
    ... this is really easy by just modifying the SELECT query, and add an ORDER BY...
    Controls like Listview are not always populated from the recordset so hidden columns are quite useful and serve lots of different purposes.

  10. #10

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: [RESOLVED] Invisible columns in a ListView

    Quote Originally Posted by CVMichael
    Honestly I don't understand why would you want to create a hidden column in the ListView.
    A sudden idea I had but then I realized it was stupid.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  11. #11
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: [RESOLVED] Invisible columns in a ListView

    Quote Originally Posted by krtxmrtz
    A sudden idea I had but then I realized it was stupid.
    I don't think it was (if it makes feel any better about yourself)...
    It's a matter of necessity I guess but technic is widely used and under sicumstances it could be the most robust solution.

  12. #12

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: [RESOLVED] Invisible columns in a ListView

    Quote Originally Posted by RhinoBull
    I don't think it was (if it makes feel any better about yourself)...
    Thanks for your encouraging comment.

    What I meant was, using a hidden column wasn't any good for my specific purpose but I only realized that after I'd started the thread. Namely, I had numbers in one of the columns representing the relative errors resulting from the comparison of experimental measurements with theoretical calculations. These errors were spread around 0 but could be positive or negative. I was interested in sorting the column from lowest to highest values but then I could have -10 as a smaller error than say 0.7, which made no sense. So I thought I had to sort according to the absolute values and so, eureka! I'd place those in a hidden column, but then I couldn't click on the header if I didn't see it, so finally I placed the absolute values of the errors in a visible column.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  13. #13

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