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