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. How to disable a ListViewItem?

How to disable a ListViewItem?

Scheduled Pinned Locked Moved C#
questiontutorial
6 Posts 4 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
    arefkarimi
    wrote on last edited by
    #1

    Hi gurus, I need to disable some items inside a ListView control. As far as I know ListViewItem has no Enabled property or something like it. How can I disable a ListViteItem? Thanks

    Aref

    K M 2 Replies Last reply
    0
    • A arefkarimi

      Hi gurus, I need to disable some items inside a ListView control. As far as I know ListViewItem has no Enabled property or something like it. How can I disable a ListViteItem? Thanks

      Aref

      K Offline
      K Offline
      KennyPatel
      wrote on last edited by
      #2

      Hi Dear, I don't know ListViewItem control in 2005. But if you had you can do Visible true false only in RowDataBound Events only...... You have to find control by Casting it you can do visible true false; Thanks:laugh:

      "Good Thing Goes With Good People..."

      1 Reply Last reply
      0
      • A arefkarimi

        Hi gurus, I need to disable some items inside a ListView control. As far as I know ListViewItem has no Enabled property or something like it. How can I disable a ListViteItem? Thanks

        Aref

        M Offline
        M Offline
        mav northwind
        wrote on last edited by
        #3

        Hi! What do you mean by "disabling" a LVItem? Should it get a different color? Should the user not be able to select the item? Should doubleclicking it perform differently than it does with other LVItems? Please specify more clearly.

        Regards, mav -- Black holes are the places where God divided by 0...

        A 1 Reply Last reply
        0
        • M mav northwind

          Hi! What do you mean by "disabling" a LVItem? Should it get a different color? Should the user not be able to select the item? Should doubleclicking it perform differently than it does with other LVItems? Please specify more clearly.

          Regards, mav -- Black holes are the places where God divided by 0...

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

          It is pretty clear that what Enabled and Disabled mean. As you mentioned , Disable items must look Gray and could not be selected. Also their Click, Doubleclick and other such events must not be triggered. thanks

          Aref

          M D 2 Replies Last reply
          0
          • A arefkarimi

            It is pretty clear that what Enabled and Disabled mean. As you mentioned , Disable items must look Gray and could not be selected. Also their Click, Doubleclick and other such events must not be triggered. thanks

            Aref

            M Offline
            M Offline
            mav northwind
            wrote on last edited by
            #5

            Since MS didn't include an Enabled property for LVItems, it seems it isn't "pretty clear" what you consider a disabled item to be. ListViewItems are no controls on their own behalf, just like TreeNodes they are dependent from their containing parent control. Thus, Enabled does not have an inherent meaning by itself for child elements of controls. You'll have to implement whatever meaning you want "Enabled" to have on your own. "Their Click, Doubleclick and other such events" doesn't make sense, either - a LVItem doesn't fire these events, its containing ListView does. So if you want a ListView that can handle additional properties for its Items, you'll have to roll your own (i.e. derive from ListView and catch the appropriate events).

            Regards, mav -- Black holes are the places where God divided by 0...

            1 Reply Last reply
            0
            • A arefkarimi

              It is pretty clear that what Enabled and Disabled mean. As you mentioned , Disable items must look Gray and could not be selected. Also their Click, Doubleclick and other such events must not be triggered. thanks

              Aref

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Mav is dead on with his response. In order to do this, you'd have to roll your own ListView and ListViewItem classes to expose this kind of functionality. If you don't want to do that, you could always just remove the disabled items from the ListView. You really should read up on Windows GUI design guide. In there, it'll tell you why what you're doing is a bad idea. Something about a "consistant user experience". A ListView control is expected to provide a list of valid and selectable items. Turning off some items is an unexpected behavior for the control, thereby leading to confusion about how the control really works.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              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