Solved

How to: Hide a Column in ListView

Posted on 2002-06-23
6
1,377 Views
Last Modified: 2008-02-01
Hi all,

I am using several ListViews to display records.  The last column of each LV contains the record number of each record but are not displayed in the header, which is set to 0 width and has no text.  This is convenient since when the user sorts a column the record numbers follow each row for later retrieval.  

The problem is that the column header is still there, though not obvious, and can be manipulated by the user, what’s worse is that the headers don’t size properly.  I am now using an API call with an LVSCW_AUTOSIZE_USEHEADER option, not sure if that’s the best choice, since I can either leave off the last header or include it neither of which solves the problem completely. I had been manually resizing the headers in code but this doesn’t prevent users from accessing the column either and it’s sloppy.

So in short - I need to hide the last column from the user and allow the remaining column headers to align to the width of the LV without impeding current functionality.

I’m using VB6 SP5

Thanks,

Jim
0
Comment
Question by:syntel
6 Comments
 
LVL 2

Accepted Solution

by:
egsemsem earned 200 total points
ID: 7102080
Instead of using a hidden column, you can use Tag property of ListItem, example:

Dim LVitem As ListItem

Set LVitem = LV.ListItems.Add
LVitem.Text = Data1
LVitem.SubItems(1) = Data2
LVitem.Tag = ID

Osama
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7102304
Please maintain your open questions:

Marketing Software Date: 06/01/2001 02:35AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=20128299
Comparing two date fields in a SQL query Date: 08/01/2001 09:04AM PST  
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20161641
DateTime Picker Date: 07/29/2001 06:20PM PST  
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20159943
Importing data in text format Date: 06/08/2001 07:19AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20131975
JOIN with 3 Tables Date: 05/11/2001 12:51PM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20116893
Is there a query? Date: 06/06/2002 07:08PM PST  
http://www.experts-exchange.com/jsp/qShow.jsp?ta=vbdatabases&qid=20308828
Broken IE Date: 11/23/2000 12:45AM PST
http://www.experts-exchange.com/jsp/qShow.jsp?ta=win98&qid=11952599

Anthony
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7102863
According to my experience, we cannot hide a column in ListView, instead we can set its Width to 0. Example:

ListView1.ColumnHeader(ColumnNumber).Width = 0

Cheers
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:syntel
ID: 7106368
acperkins:

I closed a couple of those.  A few of them are pending delete...and the admin made a note to leave them alone.
0
 

Author Comment

by:syntel
ID: 7106374
That should do the trick though more info on managing column headers would be helpful.

Thanks!
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7109793
syntel, is me deserve points?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now