开发者

Owner drawing control system-background

Owner draw implies that I have to code my own drawing methods.

However, how can I tell the system to draw the "system" background of my ListView item, without the text? I would like to manually draw the text, not the (blue) background.

Protecte开发者_如何学编程d 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

Using ListView in Tile view, I just see "My Text".


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜