zoukankan      html  css  js  c++  java
  • ListView hide column by easy way

    ListView hide column by easy way

    用简单方式隐藏ListView中的列

    lvData.Columns[5].Width=0;

    and

    并且

    lvData.ColumnWidthChanging += new ColumnWidthChangingEventHandler(lvMatchupList_ColumnWidthChanging);
    void lvMatchupList_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
    {
    if (e.ColumnIndex == 5 && e.NewWidth > 0)
    e.Cancel = true;
    }

    if no effects because

    可能会没有效果,因为

    In order to receive the ListView::ColumnWidthChanging, you need to enable full dragging of windows.

    Here is how to enable full dragging of windows:
    1. Go to Control Panel
    2. Click on Display
    3. On the "Display Properties" dialog go to "Appereance" tab
    4. On the "Appearance" tab click on "Effects" button - this will open the "Effects" dialog.
    5. On the "Effects" dialog see if the "Show windows contents while dragging" check box is checked. If the check box is not checked, then check it.
    6. Close the "Effects" dialog and then the "Display Properties" dialog.

    Now full dragging of windows should be enabled on your machine and the ListView should fire the ColumnWidthChanging event.

    another way

    另一种实现

    lvData.ColumnWidthChanged += new ColumnWidthChangedEventHandler(lvMatchupList_ColumnWidthChanged);
    void lvMatchupList_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
    {
    if (e.ColumnIndex == 5 && lvData.Columns[5].Width > 0)
    lvData.Columns[5].Width = 0;
    }



  • 相关阅读:
    python定制类详解
    python格式化
    python3和2的区别
    深度优先和广度优先遍历
    python偏函数
    python匿名函数
    android 应用能够安装在什么地方
    C语言文件操作函数
    病毒木马查杀实战第026篇:“白加黑”恶意程序研究(上)
    函数指针
  • 原文地址:https://www.cnblogs.com/eshizhan/p/2385008.html
Copyright © 2011-2022 走看看