Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Listview item click events

Listview item click events

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vlusardi
    wrote on last edited by
    #1

    In a winform using C#, I have a listview to which I've added some items... I want to be able to detect a double click event on an item that will tell me which item was double clicked. I've tried the double click event for the listview, but it has no info about which item was clicked... I need listview item event info.. can someone give me some advice as to how this can be done...? thanks.

    J C 2 Replies Last reply
    0
    • V vlusardi

      In a winform using C#, I have a listview to which I've added some items... I want to be able to detect a double click event on an item that will tell me which item was double clicked. I've tried the double click event for the listview, but it has no info about which item was clicked... I need listview item event info.. can someone give me some advice as to how this can be done...? thanks.

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      vlusardi wrote: can someone give me some advice as to how this can be done...? Use the ListView's GetItemAt method to retrieve the item which was clicked. You get the point that was clicked by using the static Control.MousePosition property, then pass that through the ListView's PointToClient method (to convert from screen coordinates to ones relative to the listview). f.e

      ListViewItem lvi = myListView.GetItemAt(
      myListView.PointToClient(Control.MousePosition)
      );

      HTH, James "It is self repeating, of unknown pattern" Data - Star Trek: The Next Generation

      1 Reply Last reply
      0
      • V vlusardi

        In a winform using C#, I have a listview to which I've added some items... I want to be able to detect a double click event on an item that will tell me which item was double clicked. I've tried the double click event for the listview, but it has no info about which item was clicked... I need listview item event info.. can someone give me some advice as to how this can be done...? thanks.

        C Offline
        C Offline
        chito
        wrote on last edited by
        #3

        Set Activation property of ListView to 'Standard' and in 'ItemActivate Event' of ListView use the following code to get listview item info - ListViewItem itms = listView.SelectedItems[0];

        V 1 Reply Last reply
        0
        • C chito

          Set Activation property of ListView to 'Standard' and in 'ItemActivate Event' of ListView use the following code to get listview item info - ListViewItem itms = listView.SelectedItems[0];

          V Offline
          V Offline
          vlusardi
          wrote on last edited by
          #4

          that's what I was looking for, thanks a lot.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups