Question hide Listview column

r@Lph

New member
Joined
Jul 26, 2011
Messages
3
Programming Experience
Beginner
can any one tell me or teach me how to hide column in Listview or lock a Listview in run time :)
 
If you set the width to zero, the user can adjust it (if they notice it when playing around with the program) and able to see what you were trying to hide.

Personally if I am hiding something, I want it to stay hidden from the user. What I do is listview.column(#).dispose after populating the listview. This will dispose of the column so it is not accessable to the end user and you can still pull the information from doing listview.items(#).subitems(#) to pull back the information you might need later on.

I do this alot with applications that deal with DBs and I need to pull the ID of the record from the DB so I know which record to update but don't want the end user to see the record ID.
 
I like the idea of disposing the column after populating. I didn't realise that that would not just shuffle the subitems down one column. Of course, it does mean that you can't add any more items or redisplay the column without repopulating the list.

I think a better option is to just not use a ListView, unless you absolutely must. Unless you need grouping or multiple views, you should just use a DataGridView instead. It is a genuine grid control, which a ListView is not.
 
Back
Top