简体   繁体   中英

Is it possible to make a SubItem clickable in a ListView

i am trying to add two coloumns to a listview one for something and one for something else but it will not let me select the subitem only the original item is there anyways to fix this without using full row select? I also have to be able to load items from a txt file so datagridview will not work for this. Thanks

I suppose that DataGridView is more suitable for what you're trying to do. Sub items in ListView are not meant to be clicked individually.

If you use the ListView of WindowsForms framework you can assign a MouseDown event handler:

private void listView1_MouseDown(object sender, MouseEventArgs e)
{
  Console.Out.WriteLine("e.X = {0}, e.Y={1}", e.X, e.Y);
}

Here you has the point where mouse clicked on within ListView control. Now you can compute the column index because you know the width of everey column.

Not very comfortable but a fallback if you do not find another solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM