Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6655611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:32:27+00:00 2026-05-26T01:32:27+00:00

In Windows Explorer (at least in Win7) when you hover the mouse over a

  • 0

In Windows Explorer (at least in Win7) when you hover the mouse over a column header, a filter box with an arrow appears that lets you filter the results in the ListView, so for example you can only show files starting with “A” or files > 128 MB. Can this feature be enabled in the basic ListView control in C# without subclassing or modifying the ListView?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:32:28+00:00Added an answer on May 26, 2026 at 1:32 am

    Here’s some code to play with. Add a new class to your project and paste the code shown below. Compile. Drop the new ListViewEx control from the top of the toolbox onto your form. In the form constructor, call the SetHeaderDropdown() method to enable the button. Implement the HeaderDropdown event to return a control to display. For example:

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            listViewEx1.SetHeaderDropdown(0, true);
            listViewEx1.HeaderDropdown += listViewEx1_HeaderDropdown;
        }
    
        void listViewEx1_HeaderDropdown(object sender, ListViewEx.HeaderDropdownArgs e) {
            e.Control = new UserControl1();
        }
    }
    

    The below code has a flaw, the popup is displayed in a form. Which can’t be too small and takes the focus away from the main form. Check this answer on hints how to implement a control that can be displayed as a toplevel window without needing a form. The code:

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    class ListViewEx : ListView {
        public class HeaderDropdownArgs : EventArgs {
            public int Column { get; set; }
            public Control Control { get; set; }
        }
        public event EventHandler<HeaderDropdownArgs> HeaderDropdown;
    
        public void SetHeaderDropdown(int column, bool enable) {
            if (column < 0 || column >= this.Columns.Count) throw new ArgumentOutOfRangeException("column");
            while (HeaderDropdowns.Count < this.Columns.Count) HeaderDropdowns.Add(false);
            HeaderDropdowns[column] = enable;
            if (this.IsHandleCreated) SetDropdown(column, enable);
        }
        protected void OnHeaderDropdown(int column) {
            var handler = HeaderDropdown;
            if (handler == null) return;
            var args = new HeaderDropdownArgs() { Column = column };
            handler(this, args);
            if (args.Control == null) return;
            var frm = new Form();
            frm.FormBorderStyle = FormBorderStyle.FixedSingle;
            frm.ShowInTaskbar = false;
            frm.ControlBox = false;
            args.Control.Location = Point.Empty;
            frm.Controls.Add(args.Control);
            frm.Load += delegate { frm.MinimumSize = new Size(1, 1);  frm.Size = frm.Controls[0].Size; };
            frm.Deactivate += delegate { frm.Dispose(); };
            frm.StartPosition = FormStartPosition.Manual;
            var rc = GetHeaderRect(column);
            frm.Location = this.PointToScreen(new Point(rc.Right - SystemInformation.MenuButtonSize.Width, rc.Bottom));
            frm.Show(this.FindForm());
        }
    
        protected override void OnHandleCreated(EventArgs e) {
            base.OnHandleCreated(e);
            if (this.Columns.Count == 0 || Environment.OSVersion.Version.Major < 6 || HeaderDropdowns == null) return;
            for (int col = 0; col < HeaderDropdowns.Count; ++col) {
                if (HeaderDropdowns[col]) SetDropdown(col, true);
            }
        }
    
        private Rectangle GetHeaderRect(int column) {
            IntPtr hHeader = SendMessage(this.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
            RECT rc;
            SendMessage(hHeader, HDM_GETITEMRECT, (IntPtr)column, out rc);
            return new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
        }
    
        private void SetDropdown(int column, bool enable) {
            LVCOLUMN lvc = new LVCOLUMN();
            lvc.mask = LVCF_FMT;
            lvc.fmt = enable ? LVCFMT_SPLITBUTTON : 0;
            IntPtr res = SendMessage(this.Handle, LVM_SETCOLUMN, (IntPtr)column, ref lvc);
        }
    
        protected override void WndProc(ref Message m) {
            Console.WriteLine(m);
            if (m.Msg == WM_NOTIFY) {
                var hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
                if (hdr.code == LVN_COLUMNDROPDOWN) {
                    var info = (NMLISTVIEW)Marshal.PtrToStructure(m.LParam, typeof(NMLISTVIEW));
                    OnHeaderDropdown(info.iSubItem);
                    return;
                }
            }
            base.WndProc(ref m);
        }
    
        private List<bool> HeaderDropdowns = new List<bool>();
    
        // Pinvoke
        [DllImport("user32.dll")]
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
        [DllImport("user32.dll")]
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, ref LVCOLUMN lvc);
        [DllImport("user32.dll")]
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, out RECT rc);
        [DllImport("user32.dll")]
        private static extern IntPtr SetParent(IntPtr hWnd, IntPtr hParent);
    
        private const int LVM_SETCOLUMN = 0x1000 + 96;
        private const int LVCF_FMT = 1;
        private const int LVCFMT_SPLITBUTTON = 0x1000000;
        private const int WM_NOTIFY = 0x204e;
        private const int LVN_COLUMNDROPDOWN = -100 - 64;
        private const int LVM_GETHEADER = 0x1000 + 31;
        private const int HDM_GETITEMRECT = 0x1200 + 7;
    
    
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct LVCOLUMN {
            public uint mask;
            public int fmt;
            public int cx;
            public string pszText;
            public int cchTextMax;
            public int iSubItem;
            public int iImage;
            public int iOrder;
            public int cxMin;
            public int cxDefault;
            public int cxIdeal;
        }
    
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct POINT {
            public int x, y;
        }
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct RECT {
            public int left, top, right, bottom; 
        }
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct NMHDR {
            public IntPtr hwndFrom;
            public IntPtr idFrom;
            public int code;
        }
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct NMLISTVIEW {
            public NMHDR hdr;
            public int iItem;
            public int iSubItem;
            public uint uNewState;
            public uint uOldState;
            public uint uChanged;
            public POINT ptAction;
            public IntPtr lParam;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to kill windows explorer's process (explorer.exe), for that lets say i use
I'm hacking together something that lists every window on my Windows box, and it
I created a windows explorer toolbar in C#. This toolbar is removed when uninstalling
How would I go about replacing Windows Explorer with a third party tool such
When I look at a directory in Windows Explorer, I can see a ProductName
How to inherit from the windows explorer (Desktop, thing with help of which we
I'm currently writing a Windows Explorer Shell Extension. Everything is ok so far but
Is there any way of launching Windows Explorer from ant without stopping the build?
I can create a menu item in the Windows Explorer context menu by adding
SUMMARY: When browsing an ASP.NET website using Windows Explorer, popup windows do not borrow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.