我已经设置了100个图片框并使用抽象字符串添加了一个文本元素。我使用as循环来更新文本,同时我设置了图片框背景颜色。循环之后,并不会显示所有文本。有些是空白的,有些显示但是间歇性的。
Private Sub LoadStepPatternFlash()
intBank = intSequenceNumber * 100
For intCounter = 0 To 99
Dim g As Graphics = PicPixel(intCounter).CreateGraphics()
PicPixel(intCounter).BackColor = Color.FromArgb(intPatternColorsRed(strhexPixelHexValue(intCounter + intBank)), intPatternColorsGreen(strhexPixelHexValue(intCounter + intBank)), intPatternColorsBlue(strhexPixelHexValue(intCounter + intBank)))
g.DrawString(strhexPixelHexValue(intCounter + intBank), New Font("Arial", 10), Brushes.White, 1, 1)
' PicPixel(intCounter).Refresh()
Next
End Sub
如果我在endsub上放置断点,那么F5(继续)文本每次都显示正常。有什么想法吗?
答案 0 :(得分:0)
找到一个修复,我没有在图片框上绘图,但我创建了一个位图并在位图上绘制,然后将位图图像发布到图片框。所有问题都得到了解决。
Private Sub LoadStepPatternFlash()
Dim NG As Graphics
Dim Color_Background As Color
Dim Brush_Background As Brush
Dim LastColorIndicator As Color
Dim LastColorBrush As Brush
Dim bmp As Bitmap
intBank = intSequenceNumber * 100
If intSequenceNumber > 0 Then
intLastBank = (intSequenceNumber - 1) * 100
End If
For intCounter = 0 To 99
Dim Pen As Pen = New Pen(Color.White)
bmp = New Bitmap(Pb_Seg1.Image) '//Image is white bitmap
NG = Graphics.FromImage(bmp)
Color_Background = Color.FromArgb(intPatternColorsRed(strhexPixelHexValue(intCounter + intBank)), intPatternColorsGreen(strhexPixelHexValue(intCounter + intBank)), intPatternColorsBlue(strhexPixelHexValue(intCounter + intBank)))
Brush_Background = New SolidBrush(Color_Background)
NG.FillRectangle(Brush_Background, 0, 0, 30, 30)
LastColorIndicator = Color.FromArgb(intPatternColorsRed(strhexPixelHexValue(intCounter + intLastBank)), intPatternColorsGreen(strhexPixelHexValue(intCounter + intLastBank)), intPatternColorsBlue(strhexPixelHexValue(intCounter + intLastBank)))
LastColorBrush = New SolidBrush(LastColorIndicator)
NG.FillRectangle(LastColorBrush, 0, 0, 12, 12)
NG.DrawRectangle(Pen, 0, 0, 12, 12)
Pen.Dispose()
If ShowPixelNumber Then
NG.DrawString((intCounter + 1), New Font("Arial", 8), Brushes.White, 20, 20)
End If
If ShowColorNumber Then
NG.DrawString(strhexPixelHexValue(intCounter + intBank), New Font("Arial", 8), Brushes.White, 1, 1)
End If
PicPixel(intCounter).Image = bmp
Next
End Sub