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;
    }



  • 相关阅读:
    ajax 重复提交
    函数中对象名的传参形式
    传参格式
    字体和排版
    自学设计
    假如java类里的成员变量是自身的对象
    java中的锁之AbstractQueuedSynchronizer源码分析(一)
    java中的锁之Lock接口与Condition接口
    Comparator与Comparable用法与区别
    session与cokkie区别
  • 原文地址:https://www.cnblogs.com/eshizhan/p/2385008.html
Copyright © 2011-2022 走看看