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?
Printable View
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?
To my knowledge, that is the only way other.
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. ;)
Since columns can still be resized you may want to look at this nice sample by Aaron Young:
Preventing certain Listview columns from sizing
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.
Now I've just remembered I'd seen this thread some time ago but had completely forgotten about it.Quote:
Originally Posted by RhinoBull
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...
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. :)
Controls like Listview are not always populated from the recordset so hidden columns are quite useful and serve lots of different purposes.Quote:
Originally Posted by CVMichael
A sudden idea I had but then I realized it was stupid.Quote:
Originally Posted by CVMichael
I don't think it was (if it makes feel any better about yourself)... :)Quote:
Originally Posted by krtxmrtz
It's a matter of necessity I guess but technic is widely used and under sicumstances it could be the most robust solution.
Thanks for your encouraging comment.Quote:
Originally Posted by RhinoBull
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.
Well, as I said if it is a "necessity" and for you I guess it isn't. :thumb: