【发布时间】:2016-01-06 23:36:28
【问题描述】:
我几乎没有运气试图在 stackoverflow 上找到这个问题的答案,或者在一般的互联网上。
我在一个 vb 2015 Windows Forms 项目中有一个表单。
在那个表单上,我放置了六个控件:四个文本框、一个面板和一个按钮。
当我点击按钮时,它会生成一个位图,如下所示:
Private Sub btnSetLeft_Click(sender As Object, e As EventArgs) Handles btnSetLeft.Click
Dim R As Integer = CInt(txtRedLeft.Text)
Dim G As Integer = CInt(txtGreenLeft.Text)
Dim B As Integer = CInt(txtBlueLeft.Text)
Dim A As Integer = CInt(txtAlphaLeft.Text)
gcL = Color.FromArgb(A, R, G, B)
Using bm As Bitmap = New Bitmap(9, 9)
Using gBM As Graphics = Graphics.FromImage(bm)
Using br As SolidBrush = New SolidBrush(gcL)
gBM.FillRectangle(br, New Rectangle(0, 0, 8, 8))
End Using
End Using
End Using
End Sub
但是,在构建位图之后,我希望按钮将位图放在面板上,然后重新绘制面板,从而显示新的位图。
我该怎么做?
【问题讨论】:
-
thePanel.BackgroundImage = bm你必须将它从 USING 块中删除,这样你就不会丢弃它,这意味着如果你再次点击,你应该丢弃旧的(或重复使用同一个)