Solved

Hide a column in a CListCtrl

Posted on 2002-07-25
13
2,122 Views
Last Modified: 2013-11-20
Hi,
I have a CListCtrl which I want to hide columns in it.
I set the width of the column to zero, but this is not good enough because can be easially break by dragging the splitter.

Does anyone have any idea of how to it right ??
An example would be graet...

thanks,
Yoav.
0
Comment
Question by:yoavo
  • 4
  • 3
  • 2
  • +3
13 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
What about deleting the column from the list control when not required?
0
 

Author Comment

by:yoavo
Comment Utility
no.
I need to hide or show it on demand
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
Hi!
may be set column width  equal to 0 will help?
0
 

Author Comment

by:yoavo
Comment Utility
Thats what I did !!!
read my question !!!
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
hmm sorry
but you can catch WM_MOTIFY message from the header control
and restrict this situation:
HDN_BEGINTRACK
return TRUE to prevent divider tracking.
to do this you have to derive your own class from CListCtrl  
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
hmm sorry
but you can catch WM_MOTIFY message from the header control
and restrict this situation:
HDN_BEGINTRACK
return TRUE to prevent divider tracking.
to do this you have to derive your own class from CListCtrl  
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:yoavo
Comment Utility
I tried to do so, but I have the following problem:
Now I have 2 columns on the same devider (one with some width and the other with width = 0) and if a user trys to resize the column, he can to so only if the cursor position is from the left side of the devider !!!
if the cursor is from the right then the resize operation is blocked !
0
 
LVL 12

Expert Comment

by:migel
Comment Utility
ok
you can move column to the last position so none can resize  rightmost column :-)
see  HDM_SETORDERARRAY
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Hi,
I have an app where the user can determine which columns he wants to see (and in which order).
When the dialog in which he made his choice closes,
I delete all the existing columns [DeleteColumn()] and add again the ones he chose to see.
It works perfect.

Success.
0
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Of course you also have to repopulate your listcontrol afterwards.
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Further to my first post.  Recreate the column again if required.
0
 
LVL 1

Accepted Solution

by:
poohbear_68 earned 50 total points
Comment Utility
I suggest you move it to the far left, set the width to zero, and then use migel's suggestion to prevent divider tracking.  Nobody will ever want to resize anything on the left hand size anyway....
0
 

Expert Comment

by:exchnerd
Comment Utility
Alternatively, you can set pResult = 1 and return if you are not deriving your class from CListCtrl
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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