Solved

How to: Hide a Column in ListView

Posted on 2002-06-23
6
1,382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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 52

Expert Comment

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

690 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