0

所有者の描画は、独自の描画メソッドをコーディングする必要があることを意味します。

ListViewただし、テキストなしでアイテムの「システム」背景を描画するようにシステムに指示するにはどうすればよいですか? (青の)背景ではなく、テキストを手動で描画したいと思います。

Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawListViewItemEventArgs)
    MyBase.OnDrawItem(e)

    e.DrawBackground()
    TextRenderer.DrawText(e.Graphics, "My Text", e.Item.Font, e.Bounds, e.Item.ForeColor)
End Sub

タイルビューで使用ListViewすると、"My Text" だけが表示されます。

4

1 に答える 1

0
Protected Overrides Sub OnDrawItem(ByVal e As DrawListViewItemEventArgs)
    MyBase.OnDrawItem(e)

  e.DrawBackground()
  If (e.State And ListViewItemStates.Selected) <> 0 Then
    e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds)
    e.DrawFocusRectangle()
    TextRenderer.DrawText(e.Graphics, "My Text", e.Item.Font, e.Bounds, SystemColors.HighlightText, Color.Empty)
  Else
    TextRenderer.DrawText(e.Graphics, "My Text", e.Item.Font, e.Bounds, e.Item.ForeColor)
  End If
End Sub
于 2011-09-11T12:39:22.637 に答える