资源简介

DataGridView过滤(附带完整代码及示例)

资源截图

代码片段和文件信息

//---------------------------------------------------------------------
//  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 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         914  2011-08-02 16:35  WindowsFormsApplication2\WindowsFormsApplication2.sln
     文件       25088  2011-08-04 15:38  WindowsFormsApplication2\WindowsFormsApplication2.suo
     目录           0  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\
     文件         159  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\app.config
     目录           0  2011-08-01 15:16  WindowsFormsApplication2\WindowsFormsApplication2\bin\
     目录           0  2011-08-04 13:58  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\
     文件       35840  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
     文件         159  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe.config
     文件       69120  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
     文件       11600  2011-08-04 15:24  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
     文件         159  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.config
     文件         490  2010-03-17 22:39  WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
     目录           0  2011-08-01 15:16  WindowsFormsApplication2\WindowsFormsApplication2\bin\Release\
     文件       68492  2011-08-04 13:46  WindowsFormsApplication2\WindowsFormsApplication2\DataGridViewAutoFilterColumnHeaderCell.cs
     文件        6939  2011-08-04 13:46  WindowsFormsApplication2\WindowsFormsApplication2\DataGridViewAutoFilterTextBoxColumn.cs
     文件        9232  2011-08-04 15:22  WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs
     文件        8666  2011-08-04 14:14  WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs
     文件        6017  2011-08-04 14:14  WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx
     目录           0  2011-07-20 13:54  WindowsFormsApplication2\WindowsFormsApplication2\obj\
     目录           0  2011-07-20 13:54  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\
     目录           0  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\
     文件        4440  2011-07-22 13:42  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6410  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         380  2011-08-04 14:14  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\GenerateResource.read.1.tlog
     文件         926  2011-08-04 14:14  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\GenerateResource.write.1.tlog
     目录           0  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\TempPE\
     文件        4608  2011-08-04 13:57  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
     文件        1217  2011-08-04 15:24  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
     文件       35840  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.exe
     文件         180  2011-08-04 14:14  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.Form1.resources
     文件       69120  2011-08-04 15:23  WindowsFormsApplication2\WindowsFormsApplication2\obj\x86\Debug\WindowsFormsApplication2.pdb
............此处省略10个文件信息

评论

共有 条评论