2017-08-11 48 views
0

ListViewのオーナードローイングに問題があります。 ListViewItemにカーソルを置くと、それらのサブアイテムは消えます。もう一度クリックすると、再び表示され、表示されます。それは最初は一度だけ起こります。これは私の現在のコードです:詳細は行を超えるときにマウスポインタが移動を表示行ごとに一度あるため、基礎となるのWin32コントロールのバグのVB.NET ListView OwnerDrawサブアイテムがホバリング時に消えます

Private Sub ListView1_DrawItem(sender As Object, e As DrawListViewItemEventArgs) Handles ListView1.DrawItem 

If (e.State And ListViewItemStates.Selected) <> 0 Then 
     e.Graphics.FillRectangle(Brushes.Violet, e.Bounds) 

     Dim cBounds As Rectangle = e.Bounds 
     cBounds.X = cBounds.X + 6 

     e.Graphics.DrawString(e.Item.Text, New Font("Segoe UI", 9.25, FontStyle.Bold), Brushes.White, cBounds) 
    Else 
     e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 25, 25, 25)), e.Bounds) 

     Dim cBounds As Rectangle = e.Bounds 
     cBounds.X = cBounds.X + 6 

     e.Graphics.DrawString(e.Item.Text, New Font("Segoe UI", 9.25), Brushes.White, cBounds) 
    End If 
End Sub 

Private Sub ListView1_DrawSubItem(sender As Object, e As DrawListViewSubItemEventArgs) Handles ListView1.DrawSubItem 
    If (e.ItemState And ListViewItemStates.Selected) <> 0 Then 
     e.Graphics.FillRectangle(Brushes.Violet, e.Bounds) 

     Dim cBounds As Rectangle = e.Bounds 
     cBounds.X = cBounds.X + 6 

     e.Graphics.DrawString(e.Item.Text, New Font("Segoe UI", 9.25, FontStyle.Bold), Brushes.White, cBounds) 
    Else 
     e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(255, 25, 25, 25)), e.Bounds) 

     Dim cBounds As Rectangle = e.Bounds 
     cBounds.X = cBounds.X + 6 

     e.Graphics.DrawString(e.Item.Text, New Font("Segoe UI", 9.25), Brushes.White, cBounds) 
    End If 
End Sub 
+0

あなたが投稿したコードは、この問題を再現しません。 MouseHoverイベントまたは他のマウスイベントにコードがありますか? – LarsTech

答えて

0

、DrawItemイベントが原因、DrawSubItemイベントを伴わずに発生しますDrawSubItemイベントハンドラに描画され、DrawItemイベントハンドラに描画されたカスタム背景によってペイントされるもの。

2つの回避策については、備考欄hereを参照してください。

関連する問題