list view: why GetItemAt method does not work?

  • Thread starter Thread starter Linda Chen
  • Start date Start date
L

Linda Chen

I am using list view control, try to find the sub item
clicked by the mouse.Inside mouse_down method, I use
GetItemAt method but it always return me null value, here
is my sample code:

private void listView1_MouseDown(object sender,
MouseEventArgs e)
{
ListViewSubItem subItem =
this.GetListViewSubItem
(this.listFileHistory, new Point(e.X, e.Y), 4);

if (subItem != null)
{
string tmp = subItem.Text;
}*/

System.Windows.Forms.ListViewItem
item = this.listFileHistory.GetItemAt(e.X, e.Y);

int aaaa = 0;
}
 
Since you are asking for sub items, I assume you are using the 'Details'
view. Do you have the property 'FullRowSelect' set to true on the listview?
If not, make sure it is set to true since otherwise you will not be able to
get the sub items for the item.

hope that helps..
Imran.
 
Back
Top