【问题标题】:Prevent over-wrapped line draw when using DrawRect or DrawBorder使用 DrawRect 或 DrawBorder 时防止过度包裹线绘制
【发布时间】:2014-01-24 09:34:13
【问题描述】:

Private Sub pancontrols_Paint(sender As Object, e As PaintEventArgs) Handles pancontrols.Paint

    e.Graphics.Clear(Color.Yellow)
    Dim borderWidth As Integer = 1
    Dim theColor As Color = Color.Gray
    ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, theColor, borderWidth, ButtonBorderStyle.Solid, theColor, borderWidth, ButtonBorderStyle.Solid, theColor, borderWidth, ButtonBorderStyle.Solid, theColor, borderWidth, ButtonBorderStyle.Solid)
    MyBase.OnPaint(e)
End Sub

代码如上。

当我调整大小时,尤其是调整大小以增加宽度时,绘制的线条仍然存在。

即使我清除了纯色的e.Graphics,问题仍然存在。

有什么简单的方法可以防止这种情况发生吗?

谢谢!

【问题讨论】:

    标签: vb.net winforms visual-studio-2010 visual-studio


    【解决方案1】:

    尝试在面板的构造函数中使用 this 使 resize 事件无效:

    Public Sub New()
      Me.DoubleBuffered = True
      Me.ResizeRedraw = True
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      相关资源
      最近更新 更多