打印本文 打印本文 关闭窗口 关闭窗口
使用vb.net 对 Windows Form 按列排序 ListView 项目
作者:武汉SEO闵涛  文章来源:敏韬网  点击数8095  更新时间:2009/4/23 19:00:36  文章录入:mintao  责任编辑:mintao
nbsp;   End If

        Return returnVal

    End Function

//C#

public int Compare(object x, object y)

{

    int returnVal;

    // Determine whether the type being compared is a date type.

    try

    {

        // Parse the two objects passed as a parameter as a DateTime.

        System.DateTime firstDate =

                DateTime.Parse(((ListViewItem)x).SubItems[col].Text);

        System.DateTime secondDate =

                DateTime.Parse(((ListViewItem)y).SubItems[col].Text);

        // Compare the two dates.

        returnVal = DateTime.Compare(firstDate, secondDate);

    }

    // If neither compared object has a valid date format, compare

    // as a string.

    catch

    {

        // Compare the two items as a string.

        returnVal = String.Compare(((ListViewItem)x).SubItems[col].Text,

                    ((ListViewItem)y).SubItems[col].Text);

    }

    // Determine whether the sort order is descending.

    if (order == SortOrder.Descending)

    // Invert the value returned by String.Compare.

        returnVal *= -1;

    return returnVal;

}

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  下一页

打印本文 打印本文 关闭窗口 关闭窗口