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. Visual Basic
  4. ListView DrawItem() e.Bounds gives different Height when item is selected. SOLVED.

ListView DrawItem() e.Bounds gives different Height when item is selected. SOLVED.

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 2 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.
  • M Offline
    M Offline
    mo1492
    wrote on last edited by
    #1

    I have a ListView with OwnerDraw enabled and I am processing just DrawItem(). I am using LargeImageList with 48 x 48 ImageSize and View = MediumIcons. When I rename an item to cause the text to wrap and thereby causing the height of the item to increase, every thing is ok while the item is selected; ie. Has Focus. When I select a different item and the renamed item loses focus, e.bounds reports a reduced height which causes misalignment of text. Note: This does not occur when wrapping results with 2 lines. But does occur when there are 3 lines. What am I missing? Thank you Private Sub OpenFileDialogListView_DrawItem(ByVal sender As Object, ByVal e As DrawListViewItemEventArgs) Handles MyBase.DrawItem ' Start of function. No preceding code. ' If I break here when item is selected, e.bounds.height = 94. ' When not selected, e.bounds.height = 81. e.DrawBackground() End Sub

    L 1 Reply Last reply
    0
    • M mo1492

      I have a ListView with OwnerDraw enabled and I am processing just DrawItem(). I am using LargeImageList with 48 x 48 ImageSize and View = MediumIcons. When I rename an item to cause the text to wrap and thereby causing the height of the item to increase, every thing is ok while the item is selected; ie. Has Focus. When I select a different item and the renamed item loses focus, e.bounds reports a reduced height which causes misalignment of text. Note: This does not occur when wrapping results with 2 lines. But does occur when there are 3 lines. What am I missing? Thank you Private Sub OpenFileDialogListView_DrawItem(ByVal sender As Object, ByVal e As DrawListViewItemEventArgs) Handles MyBase.DrawItem ' Start of function. No preceding code. ' If I break here when item is selected, e.bounds.height = 94. ' When not selected, e.bounds.height = 81. e.DrawBackground() End Sub

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I have a similar app written in C++. When the view is in "Large Icon" mode then the text is restricted to two lines (with a trailing ellipsis). However, when an item is focused it shows all three lines. Thus the height of the item varies between focused and unfocused.

      M 1 Reply Last reply
      0
      • L Lost User

        I have a similar app written in C++. When the view is in "Large Icon" mode then the text is restricted to two lines (with a trailing ellipsis). However, when an item is focused it shows all three lines. Thus the height of the item varies between focused and unfocused.

        M Offline
        M Offline
        mo1492
        wrote on last edited by
        #3

        You beat me. I just created a test app in Mfc myself and found that out. I was confused because Explorer somehow displays 3 lines. Must be custom control because Spy does not show what kind of control it is. Thanks a for your help. ;)

        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