[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2385
  • Last Modified:

Hide a column in a CListCtrl

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
yoavo
Asked:
yoavo
  • 4
  • 3
  • 2
  • +3
1 Solution
 
AndyAinscowFreelance programmer / ConsultantCommented:
What about deleting the column from the list control when not required?
0
 
yoavoAuthor Commented:
no.
I need to hide or show it on demand
0
 
migelCommented:
Hi!
may be set column width  equal to 0 will help?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
yoavoAuthor Commented:
Thats what I did !!!
read my question !!!
0
 
migelCommented:
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
 
migelCommented:
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
 
yoavoAuthor Commented:
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
 
migelCommented:
ok
you can move column to the last position so none can resize  rightmost column :-)
see  HDM_SETORDERARRAY
0
 
zzynxSoftware engineerCommented:
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
 
zzynxSoftware engineerCommented:
Of course you also have to repopulate your listcontrol afterwards.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Further to my first post.  Recreate the column again if required.
0
 
poohbear_68Commented:
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
 
exchnerdCommented:
Alternatively, you can set pResult = 1 and return if you are not deriving your class from CListCtrl
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now