How to hide a column in a ListView control?

后端 未结 9 2369
慢半拍i
慢半拍i 2021-02-14 03:01

How can I hide a column in a ListView control, without setting the column Width property to 0?

Also, can I lock the Width

9条回答
  •  忘掉有多难
    2021-02-14 03:15

    Not very clear what matters here C++Cli tag, but:

    I presume that if you're talking about a columns in ListView, you're in details view of the control. There is no builtin Hide/Show column way in ListView, as much as I'm aware of, so one of solutions can be just remove that column form UI.

    To do that in most smooth way possible just call your ListView column regeneration code in between

    listView.SuspendLayout(true);
    
    /*Manipulate column here*/
    
    listView.ResumeLayout();
    

    The data which is visible on ListView always remains "in your hands", so at the moment you will decide to show the column again, just show the column and fill ListView again.

    Hope this helps.

提交回复
热议问题