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. Regarding selectedindexchange event in listview

Regarding selectedindexchange event in listview

Scheduled Pinned Locked Moved C#
helpquestion
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.
  • A Offline
    A Offline
    anu81
    wrote on last edited by
    #1

    hi all, I have customized listview to display images in thumbnail view as in windows explorer. I have set ownerdraw property as true and used the drawitem event of listview to redraw the listview. Now when i click any item in the listview, the selectedindexchange event is fired twice. Why is the event firing twice? What could be the problem? Any suggestions please.

    Thanks in advance.:) Regards Anuradha

    T L 2 Replies Last reply
    0
    • A anu81

      hi all, I have customized listview to display images in thumbnail view as in windows explorer. I have set ownerdraw property as true and used the drawitem event of listview to redraw the listview. Now when i click any item in the listview, the selectedindexchange event is fired twice. Why is the event firing twice? What could be the problem? Any suggestions please.

      Thanks in advance.:) Regards Anuradha

      T Offline
      T Offline
      TJoe
      wrote on last edited by
      #2

      Without any code it's really impossible to tell. But chances are it's not related to your custom draw code. I would guess that it's related to your code that hooks up the SelectedIndexChanged event. Unless you explicitly firing that event in your custom ListView control.

      Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

      1 Reply Last reply
      0
      • A anu81

        hi all, I have customized listview to display images in thumbnail view as in windows explorer. I have set ownerdraw property as true and used the drawitem event of listview to redraw the listview. Now when i click any item in the listview, the selectedindexchange event is fired twice. Why is the event firing twice? What could be the problem? Any suggestions please.

        Thanks in advance.:) Regards Anuradha

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, some Controls with selection capabilities fire twice: once when they unselect the existing selection, and again when they apply the new selection. Check the EventArgs to get the details, and you will know whether it is this phenomenon, rather than the exactly same event firing twice. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        A 1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, some Controls with selection capabilities fire twice: once when they unselect the existing selection, and again when they apply the new selection. Check the EventArgs to get the details, and you will know whether it is this phenomenon, rather than the exactly same event firing twice. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          A Offline
          A Offline
          anu81
          wrote on last edited by
          #4

          hi, I have found one solution which seems to be working fine. but still i would like to have a better and liable solution. in the selectedindexchange event i wrote the following code. private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) MessageBox.Show("Clicked"); } is this solution right?

          Thanks in advance.:) Regards Anuradha

          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