资源简介

DataGridView列标头带数据筛选功能(含C#源码DEMO)), 类似Excel筛选功能的 DataGridView 源代码,调用简单,功能好用,C#示例都有。筛选后状态栏显示过滤后的条数及显示全部的HPLINK标签按钮。

资源截图

代码片段和文件信息

//---------------------------------------------------------------------
//  Copyright (C) Microsoft Corporation.  All rights reserved.
// 
//THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE
//IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Visualstyles;
using System.Collections;
using System.Reflection;

namespace DataGridViewAutoFilter
{
    /// 
    /// Provides a drop-down filter list in a DataGridViewColumnHeaderCell.
    /// 

    public class DataGridViewAutoFilterColumnHeaderCell : DataGridViewColumnHeaderCell
    {
        /// 
        /// The ListBox used for all drop-down lists. 
        /// 

        private static FilterListBox dropDownListBox = new FilterListBox();

        /// 
        /// A list of filters available for the owning column stored as 
        /// formatted and unformatted string values. 
        /// 

        private System.Collections.Specialized.OrderedDictionary filters =
            new System.Collections.Specialized.OrderedDictionary();

        /// 
        /// The drop-down list filter value currently in effect for the owning column. 
        /// 

        private String selectedFilterValue = String.Empty;

        /// 
        /// The complete filter string currently in effect for the owning column. 
        /// 

        private String currentColumnFilter = String.Empty;

        /// 
        /// Indicates whether the DataGridView is currently filtered by the owning column.  
        /// 

        private Boolean filtered;

        /// 
        /// Initializes a new instance of the DataGridViewColumnHeaderCell 
        /// class and sets its property values to the property values of the 
        /// specified DataGridViewColumnHeaderCell.
        /// 

        /// The DataGridViewColumnHeaderCell to copy property values from.
        public DataGridViewAutoFilterColumnHeaderCell(DataGridViewColumnHeaderCell oldHeaderCell)
        {
            this.ContextMenuStrip = oldHeaderCell.ContextMenuStrip;
            this.ErrorText = oldHeaderCell.ErrorText;
            this.Tag = oldHeaderCell.Tag;
            this.ToolTipText = oldHeaderCell.ToolTipText;
            this.Value = oldHeaderCell.Value;
            this.ValueType = oldHeaderCell.ValueType;

            // Use Hasstyle to avoid creating a new style object
            // when the style property has not previously been 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2007-12-04 14:48  CS\
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\
     文件        1977  2007-11-28 12:13  CS\DataGridViewAutoFilter\DataGridViewAutoFilter.sln
     文件        2173  2007-11-28 12:13  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\DataGridViewAutoFilter.csproj
     文件       68492  2007-11-28 15:33  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\DataGridViewAutoFilterColumnHeaderCell.cs
     文件        6939  2007-11-28 12:13  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\DataGridViewAutoFilterTextBoxColumn.cs
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\Properties\
     文件        1419  2007-11-28 12:13  CS\DataGridViewAutoFilter\DataGridViewAutoFilter\Properties\AssemblyInfo.cs
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\DesignerSetupDemo\
     文件           1  2007-12-03 15:15  CS\DataGridViewAutoFilter\DesignerSetupDemo\ClassDiagram1.cd
     文件        4166  2007-12-03 15:16  CS\DataGridViewAutoFilter\DesignerSetupDemo\DesignerSetupDemo.csproj
     文件        2812  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\DesignerSetupForm.cs
     文件       10666  2007-12-04 12:03  CS\DataGridViewAutoFilter\DesignerSetupDemo\DesignerSetupForm.Designer.cs
     文件        6432  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\DesignerSetupForm.resx
     文件         496  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Program.cs
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\
     文件        1286  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\AssemblyInfo.cs
     文件        2861  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\Resources.Designer.cs
     文件        5612  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\Resources.resx
     文件        1100  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\Settings.Designer.cs
     文件         249  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\Properties\Settings.settings
     文件       32186  2007-12-04 12:03  CS\DataGridViewAutoFilter\DesignerSetupDemo\TestData.Designer.cs
     文件           3  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\TestData.xsc
     文件        1114  2007-12-04 12:04  CS\DataGridViewAutoFilter\DesignerSetupDemo\TestData.xsd
     文件           3  2007-11-28 15:01  CS\DataGridViewAutoFilter\DesignerSetupDemo\TestData.xss
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\ProgrammaticSetupDemo\
     文件         504  2007-11-28 12:13  CS\DataGridViewAutoFilter\ProgrammaticSetupDemo\Program.cs
     文件        3261  2007-11-28 12:13  CS\DataGridViewAutoFilter\ProgrammaticSetupDemo\ProgrammaticSetupDemo.csproj
     文件        5290  2007-11-28 12:13  CS\DataGridViewAutoFilter\ProgrammaticSetupDemo\ProgrammaticSetupForm.cs
     目录           0  2007-12-04 14:48  CS\DataGridViewAutoFilter\ProgrammaticSetupDemo\Properties\
............此处省略7个文件信息

评论

共有 条评论