This documentation is archived and is not being maintained.

ListViewItem.GetSubItemAt Method

Returns the subitem of the ListViewItem at the specified coordinates.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ListViewItem..::..ListViewSubItem GetSubItemAt(
	int x,
	int y


Type: System.Int32
The x-coordinate.
Type: System.Int32
The y-coordinate.

Return Value

Type: System.Windows.Forms.ListViewItem.ListViewSubItem
The ListViewItem.ListViewSubItem at the specified x- and y-coordinates.

The GetSubItemAt method will return null if the ListView is not in Details view, or there is not a ListViewItem.ListViewSubItem located at the specified point.

The following code example demonstrates how to use the GetSubItemAt method. To run this code, paste it into a Windows Form and call InitializeListView1 from the form's constructor or Load event-handling method.

private ListView listView1;

private void  InitializeListView1(){
    listView1 = new ListView();

    // Set the view to details to show subitems.
    listView1.View = View.Details;

    // Add some columns and set the width.
    listView1.Width = 175;

    // Create some items and subitems; add the to the ListView.
    ListViewItem item1 = new ListViewItem("Widget");
    item1.SubItems.Add(new ListViewItem.ListViewSubItem(item1, "14"));
    item1.SubItems.Add(new ListViewItem.ListViewSubItem(item1, 
        "A description of Widget"));
    ListViewItem item2 = new ListViewItem("Bracket");
    item2.SubItems.Add(new ListViewItem.ListViewSubItem(item2, "8"));

    // Add the ListView to the form.
    listView1.MouseDown += new MouseEventHandler(listView1_MouseDown);

void listView1_MouseDown(object sender, MouseEventArgs e)
    // Get the item at the mouse pointer.
    ListViewHitTestInfo info = listView1.HitTest(e.X, e.Y);

    ListViewItem.ListViewSubItem subItem = null;

    // Get the subitem 120 pixels to the right.
    if (info != null)
        if (info.Item != null)
            subItem = info.Item.GetSubItemAt(e.X + 120, e.Y);

    // Show the text of the subitem, if found.
    if (subItem != null)

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.