C Gets the Item instance under the ListView mouse

  • 2021-11-24 02:44:51
  • OfStack

ListView is in virtual mode, and CheckBox cannot be clicked, so it can be realized by this method


private void lvwTitle_MouseDown(object sender, MouseEventArgs e)

    {
      Point curPos = this.lvwTitle.PointToClient(Control.MousePosition);
      ListViewItem lvwItem = this.lvwTitle.GetItemAt(curPos.X, curPos.Y);


      if (lvwItem != null)
      {
        lvwItem.Checked = !lvwItem.Checked;
        lvwTitle.Refresh();
      } 
      
    } 

Related articles: